Inbound Mail AWS
(PDF)
Posted April 10th, 2024
Amazon AWS limits inbound smtp requests.
If you set up an aws EC2 instance and use an elastic IP - the incoming smtp is blocked. Don't let anyone kid you - its a fact. It doesn't matter if you adjust your security group to allow incoming smtp. So what is the alternative? The answer I came up with today is forwardemail.net It allows you to assign mx servers and route your email. It allows you to route to a specific mailbox AND, AND, AND it allows you to setup a webhook to post to when emails are sent. A webhook is a piece of code on a server that accepts a payload. In this case its a json with the wad of an email each time that someone sends an email to a particular domain. The documentation from forwardemail.net on the particular json packet sent is non existent - but it doesn't matter once you see the json. Ok - so once you get the wad of json - the next thing is to parse the email. Again this is a piece of arcana that is a bit weak on documentation. 1. php has mailparse - this is a pecl addition to parse mime emails. 2. there is a library that uses the pecl library mailparse. php-mime-mail-parser is a php library that supposedly is supported for php 8+ And if you are going to mess with this stuff believe me, you want to be able to have baseline to test emails with: Here is a link to a really solid tool to send emails: https://sendtestemail.com Ok, don't forget the implications of a) SPF b) DKIM C) DMARC D) Reverse DNS Here is sample code for a webhook from forwardemail.net that seems to work. The code depends on a bunch of other stuff - but it should be a good start in allowing you to grab the data.
|