So You'd Like to Send Some Email (Through Code)

#22

Oh, and here’s what I meant to say: vintage Coding Horror right here. A smart, useful article, with smart, useful comments and discussion.

#23

Are these mitigated if you just send the email through your email provider (such as Google Apps for Domains)? Granted, if you’re sending a lot of messages you’ll want to go with a provider, but for all of my little projects I’ve just passed all the heavy lifting to Google.

#24

@Nathan. Well said. I keep hearing these “I hate email” and “Email is dead” messages but they are bogus, because as far as I know, there is no alternative that has the characteristics that email has.

What are we going to do? Post messages on forums, twitters, blogs and hope that somebody reads it? How will you be notified though? Wouldn’t that be exactly the same as email? Instead of one source of communication and distraction we will have a dozen? How about not ignoring the fact that email is much more than communication, it is also legal proof, used as a todo, planning and scheduling application (when combined with a calendar). Some even use it as their main document management system.

There are major issues in email I admit. Spam is one and is solved mostly. Misuse and overuse is one but you will keep that in every tool, because it is about culture, not technology.

#25

@paul: “Does your address have to be public? Everyone I know who isn’t into computers like we are (which, remember, is likely 95–99% of the people in the world, and is therefore the kind of person that matters) uses Facebook instead of e-mail. There’s no real concept of a public address for messages there. You have to explicitly allow people to send you messages by becoming their friend.”

Well, that is your context. Here in the Netherlands, those people do use email, MSN and this local social network called Hyves. Your context is not universal. Guess what your group and mine have in common? Email.

The other part about context is that you are talking about the consumer space. Friending people before you can send them anything will obviously not work in an enterprise.

I can understand that Jeff and people of a similar background who use email as a consumer, not in an enterprise context, see email as annoying and outdated, but now put yourself in my shoes:

I’m currently working on 4 projects at the same time. In total it concerns a group of nearly a 100 people that I need to report to or instruct. I also need to manage and structure tasks associated with it. I need to handover stuff to newcomers. I need to archive documents. I need to be able to search through all this crap and find things fast. I need to be able to discuss things electronically and I need a record of proof for new assignments. I work with people both old and young, from various backgrounds. As far as I know, only a rich email client can do all of this.

The situation I am painting is much different from three developers in the same room working on a consumer product. Email is imperfect but often a neccessity. The alternatives are much worse.

#26

Nice article spoiled by the ‘aren’t I so alternative/idiosyncratic/eccentric by declaring my hate for email’ attention seeking.

Makes as much sense as me declaring my dislike for light switches, return-keys and cups with bottoms to keep the drink from falling out.

I really don’t see what the problem is with email. 99% of the time it just works.

How about proposing alternatives?

#27

Hey, I’m 16, and I want to learn a programming language. I’m already somewhat familiar with autoit(its basically a simpler version of visual basic, so I’m not very advanced lol) but I’d learn to learn something more mainstream and more powerful. I was thinking between C++ or Java.

People say Java is easier, but I don’t want to spoil myself with it and not be able to learn complex languages. On the other hand, I want to be able to understand the concepts of programming and not have it so complicated to where I just memorize a bunch of commands and not really understand it.

Is there a book or a website you can recommend for a first programming language? Thanks!

BTW, I also enjoy reading your blog, even though most of it is over my head.

#28

Daniel, check out Carl H’s programming lessons on Reddit.

http://www.reddit.com/r/carlhprogramming/

Start at lesson 1!

#29

The biggest bug in the code is that you insert to and subject into the mail header without any filtering. This is a source for many spam abuses, when spammers manage to control e.g. the subject and insert a newline into it, thus allowing them to insert own header lines and change the body.

#30

If you use squirrelmail, you can send messages with wget. This avoids many anti-spam and configuration issues.

wget --save-cookies cookies.txt --keep-session-cookies --post-data 'login_username=username&secretkey=password' <a href="http://webmail.server.com/src/redirect.php">http://webmail.server.com/src/redirect.php</a>

wget --load-cookies cookies.txt --post-data 'body=body here&send_to=recipient%40wherever.com&subject=subject here&send=1' <a href="http://webmail.server.com/src/compose.php">http://webmail.server.com/src/compose.php</a>

For a bit more, see:

http://mikemccabe.wordpress.com/2007/08/07/sending-email-with-squirrelmail-via-wget/

#31

Hmmm, seems to me that e-mail as a concept is still a good idea, it’s just e-mail as an implementation is broken.

I feel something more akin to Google Wave is the way forward - we need to be able to easily move between slower e-mail based communication to faster chat based communication and improve sharing of documents and other resources.

#32

Thoughts on using sendgrid.com for transactional email? I’ve used them for a few projects and love how much they do (spam, tracking, truncation).

#33

Good article if you’re only sending a single email to a single recipient. If you’re going to send email to a bunch of people, e.g. if the exam they signed up for on your website had to be canceled, you have to think about issues like rate-limiting per domain and other such headaches…

#34

I believe, if you move your emails to google app, you are good!

Also, as someone already pointed out here, if we need to mass email marketing, then we need professional email software support anyways because of throttling etc.

#35

Hi jeff why not outsource this to any one of a number of providers? They address deliverability issues which as you wrote about are the biggest hassle in the process. CPM costs are so low nowadays too. Curious why you’d want to (or have to) manage all this complexity yourself?

#36

This post basically boils down to “If you’re going to programatically plug into a global message sending service, there are some hoops you have to jump through to ensure that you’re not sending a torrent of sewage.” But this isn’t a coding problem. This is an infrastructure problem. And like most such problems, you push it off to someone else. 4/5 times your upstream ISP will have a mechanism for your network to push mail to theirs (without all these hoops) so that they become responsible for all the extra work involved in sending email. In that 5th case where they don’t, there are some pretty cheap providers who will allow you to send mail to them for a small annual fee. Then your infrastructure barrier reduces to learning to set up postfix or sendmail or whatever to use a smarthost for all outbound email.

#37
Don't even bother reading any further until you've verified that your ISP has correctly configured the reverse PTR record for the server that will be sending email.
Do mail servers configured to check PTR records actually black hole email, or do they just refuse to accept it? In my opinion an MTA either accepts an email and then does its best to deliver it, or it doesn't accept the email and produces an error message. Anything less is heinously out of spec.
#38

Below is an enlightening video about internet communication in general.

#39

I may just be thick, but I don’t understand how a PTR relates to SPF. And the Googling I’ve done, let alone the reading of articles linked from here, hasn’t made it any more clear. Anyone have a pointer to something which (relatively) clearly explains them and their relation to each other?

#40

So, the error in the “code”, is the lack of a queuing mechanism. Perhaps Ruby’s Net::SMTP does this, but somehow I doubt it. The proper way to do this is to submit the message to a local queue on the machine. That machine then relays the message through a smart host, which has the proper configurations outlined by Jeff.

#41

We send hundreds of thousands to millions of emails per day, depending on the day. You left out one important/annoying bit. You also have to contact all the major email providers ONE BY ONE to make your emails get through. Microsoft, Yahoo!, and AOL all had specific methods of getting massive amounts of e-mailing to work. Luckily they all included links in the error messages, if you read your SMTP logs.

Then you have to make sure your include all the CAN SPAM stuff (send from an address that can be replied to, double opt-in, include an unsubscribe link, etc) and also constantly monitor the common black lists. After all that, you have a decent chance of getting your emails through… It sucks.