Receives email and forwards it to your app as a JSON webhook (aka stripped down Mailgun clone).
Assuming you have Erlang and Elixir installed.
$ mix deps.get
M2J_WEBHOOK_URL
export M2J_WEBHOOK_URL="http://example.com/foo/bar"
iex -S mix
Forward port 25 to 2525 on your server
# You'll have to run the above command everytime you start the computer
# or add it permanently to your iptables.
$ sudo iptables -t nat -A PREROUTING -p tcp -m tcp --dport 25 -j REDIRECT --to-ports 2525
sudo ipfw add fwd 127.0.0.1,25 tcp from me to 127.0.0.1 dst-port 2525
Follow the local setup instructions and along with the following:
foo.example.com
example.com
A record
with the IP address of your server, that points to foo.example.com
MX record
with the value foo.example.com
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>"
}
Copyright © 2014, Akash Manohar J, under the MIT License
Basically, do whatever you want with it