Sending email via HTTP POST

A number of services have popped up lately for sending email from your web app via HTTP. Web developers know HTTP, and so enjoy the fact that they can send email this way. But they all cost money. What if you could do it yourself, for free?

So I created a Haraka plugin using Express which provides a REST API for sending emails using HTTP POST parameters to fill out the template.

It’s very simple, and could easily be extended. I’m using it from EC2 (with an Elastic IP – don’t use their normal dynamic IPs for this).

Here’s the code: https://gist.github.com/1924944. Templates should include email headers and are stored in config/mail_template, then you just POST to http://localhost:5000/SendEmail/example (if your template file is called “example”) with sender and recipient parameters encoded in the body of the request.

There’s no fancy statistics like there are for sendgrid and other such services, but you have full control and writing more plugins is as easy as pie!


6 thoughts on “Sending email via HTTP POST

  1. John says:

    First great work! I’m testing the above from localhost however it looks like emails are not delivered because of invalid mx records. How to setup MX records on mac to be able to send email from local host?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s