{"id":15713994,"url":"https://github.com/hashnuke/mail-to-json","last_synced_at":"2025-05-08T19:33:15.878Z","repository":{"id":21667179,"uuid":"24988125","full_name":"HashNuke/mail-to-json","owner":"HashNuke","description":"A MailGun.com clone in under 300 lines of Elixir","archived":false,"fork":false,"pushed_at":"2015-02-11T11:00:14.000Z","size":300,"stargazers_count":46,"open_issues_count":1,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-31T17:54:20.942Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HashNuke.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-10-09T12:27:18.000Z","updated_at":"2024-12-14T17:07:11.000Z","dependencies_parsed_at":"2022-08-19T16:50:39.965Z","dependency_job_id":null,"html_url":"https://github.com/HashNuke/mail-to-json","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HashNuke%2Fmail-to-json","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HashNuke%2Fmail-to-json/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HashNuke%2Fmail-to-json/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HashNuke%2Fmail-to-json/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HashNuke","download_url":"https://codeload.github.com/HashNuke/mail-to-json/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253135413,"owners_count":21859637,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T21:34:27.403Z","updated_at":"2025-05-08T19:33:15.845Z","avatar_url":"https://github.com/HashNuke.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MailToJson\n\nReceives email and forwards it to your app as a JSON webhook (aka stripped down [Mailgun](http://mailgun.com) clone).\n\n\n## Install application\n\nAssuming you have Erlang and Elixir installed.\n\n* Install dependencies:\n  ```shell\n  $ mix deps.get\n  ```\n* Set the webhook url by setting system env var `M2J_WEBHOOK_URL`\n  ```shell\n  export M2J_WEBHOOK_URL=\"http://example.com/foo/bar\"\n  ```\n* Follow the next section to be able to receive mail on your server\n* Start server with Elixir console: `iex -S mix`\n\n\n## Setup to receive mail\n\n#### Local setup\n\nForward port 25 to 2525 on your server\n\n* For linux\n  ```shell\n  # You'll have to run the above command everytime you start the computer\n  # or add it permanently to your iptables.\n  $ sudo iptables -t nat -A PREROUTING -p tcp -m tcp --dport 25 -j REDIRECT --to-ports 2525\n  ```\n* For Mac (I think this works. Please send a PR if it's wrong)\n  ```shell\n  sudo ipfw add fwd 127.0.0.1,25 tcp from me to 127.0.0.1 dst-port 2525\n  ```\n\n#### Remote setup (vps and such)\n\nFollow the local setup instructions and along with the following:\n\n* Let's assume that you want to receive mail on the domain `foo.example.com`\n* Note the IP address of your server\n* Add the following DNS records for `example.com`\n  * Add an `A record` with the IP address of your server, that points to `foo.example.com`\n  * Add an `MX record` with the value `foo.example.com`\n\n\n## Playing with it\n\nYou 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.\n\nThe JSON data in the webhook POST request will look like this:\n\n```javascript\n{\n  \"From\": {\n    \"name\": \"John Doe\",\n    \"email\": \"john@example.com\"\n  },\n  \"To\": [\n    {\n      \"name\": \"Jane Doe\",\n      \"email\": \"jane@example.com\"\n    }\n  ],\n  \"Subject\": \"Hello subject\",\n  \"plain_body\": \"Hello body\\r\\n\",\n  \"html_body\": \"\u003cdiv dir=\\\"ltr\\\"\u003eHello body\u003c/div\u003e\\r\\n\",\n  \"Date\": \"Thu, 16 Oct 2014 19:33:12 +0530\",\n  \"Message-ID\": \"\u003cCAEy2aia+pK5k3UqdcEPqB2JiLCRMQvyBWXtOAbV3Wmuo2QBtog@mail.gmail.com\u003e\"\n}\n```\n\n## Caveats\n\n* No security\n* No myriad of configuration\n* Doesn't handle attachments\n\n## License\n\nCopyright \u0026copy; 2014, Akash Manohar J, under the MIT License\n\nBasically, do whatever you want with it\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhashnuke%2Fmail-to-json","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhashnuke%2Fmail-to-json","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhashnuke%2Fmail-to-json/lists"}