HashNuke / mail-to-json

A MailGun.com clone in under 300 lines of Elixir
MIT License
45 stars 5 forks source link

MailToJson

Receives email and forwards it to your app as a JSON webhook (aka stripped down Mailgun clone).

Install application

Assuming you have Erlang and Elixir installed.

Setup to receive mail

Local setup

Forward port 25 to 2525 on your server

Remote setup (vps and such)

Follow the local setup instructions and along with the following:

Playing with it

You can send a test mail from your local computer from the Elixir shell itself by running MailToJson.test_mail. You should receive a log message on the shell and also a POST request at the webhook url you configured.

The JSON data in the webhook POST request will look like this:

{
  "From": {
    "name": "John Doe",
    "email": "john@example.com"
  },
  "To": [
    {
      "name": "Jane Doe",
      "email": "jane@example.com"
    }
  ],
  "Subject": "Hello subject",
  "plain_body": "Hello body\r\n",
  "html_body": "<div dir=\"ltr\">Hello body</div>\r\n",
  "Date": "Thu, 16 Oct 2014 19:33:12 +0530",
  "Message-ID": "<CAEy2aia+pK5k3UqdcEPqB2JiLCRMQvyBWXtOAbV3Wmuo2QBtog@mail.gmail.com>"
}

Caveats

License

Copyright © 2014, Akash Manohar J, under the MIT License

Basically, do whatever you want with it