So you need to send emails. Pretty simple right? Not so fast. It doesn’t matter how easy your language or framework makes sending emails, if you try to do it on your own be prepared to configure mail servers, setup Spam-related DNS entries, and still wonder if mail is actually being delivered. And your applications needs to process incoming email? Back to the config files, piping mail to your script – or just end up polling a POP or IMAP box. That’s what I had to do, back in the day. Fortunately, like so many things today, there’s an API for that. Actually there are a few.
Here’s an overview of four transactional email APIs that offer incoming and outgoing email:
(If I’ve missed one, let me know.)
If you’re integrating an API into your existing system, the ability to send mail using SMTP may make that initial process pretty painless. All but EmailYak support sending via SMTP, with various implementations.
For Postmark, your API Key is the user and password, MailGun assigns a set of SMTP credentials for your account, and SendGrid uses the login credentails for your account (the same used to log into the admin interface). Changing that behavior looks to be something SendGrid is planning to change.
EmailYak and Postmark provide an API endpoint accepting a POST with the JSON representation of an email message. Property names are different between the APIs; however, the JSON structure is relatively similar.
Mailgun and SendGrid accept a more HTTP like request, with properties sent as form parameters. SendGrid accepts a GET or a POST (being a self-described non-RESTful API), while Mailgun only accepts POST. MailGun also allows you to POST a full MIME encoded message.
With EmailYak, the callback URL can be configured to send a notification containing the message id and a few other parameters, instead of the full email data. EmailYak will also store incoming messages which can be accessed using the API.
For similar purposes MailGun allows mailboxes to be created, which can be accessed using standard POP or IMAP interfaces. Mailgun also has rich filter and routing support, allowing emails to be sent to various URLs and mailboxes depending on mail headers.
SendGrid and Mailgun provide tracking for unsubscribes, opens, and clicks, along other features. Postmark provides bounce tracking. Mailgun allows messages to be scheduled. Postmark allows your email to be segmented into ‘servers’. Each server has its own API key, and incoming email address. Mailgun and SendGrid also support email templates. SendGrid allows you to pass additional commands through SMTP headers.
Hopefully this overview has given you an idea of which API fits your needs best. Any of the four should make life easier than dealing with server configuration and incoming messages directly.