AWS EC2 Postfix Email Configuration Tips

Although the Postfix sendmail function will work out-of-the-box on an aMiSTACX deployment, here are some tips in case you run into issues.

    1. Set the main.cnf to IP4 for the interface protocol
      sudo nano /etc/postfix/main.cf
      inet_protocols = ipv4
    2. Make sure your hostname is the name of your domain. e.g., example.com
      sudo nano /etc/hostname
    3. Set the main.cf mydomain parameter to your hostname e.g. ~ Line 35: myhostname = example.com
    4. Remove AWS DNS name from ~ Line 39: mydestination = $myhostname, ip-172-30-0-139.ec2.internal, localhost.ec2.internal, , localhost
    5. Restart Postfix after any changes:
      sudo service postfix restart
    6. Make sure external DNS is configured correctly with any PNTR or SPF records
    7. Make sure outbound TCP Port 25 is open. [Sendmail’s Default and SMTP’s Default]
    8. Make sure no AWS restrictions on EMAIL.
    9. Quick test from CLI:
      echo "Subject: sendmail test" | sendmail -v my@email.com

Troubleshooting

Log files go to /var/log/mail.log and /var/mail/

If you don’t see verbose logs, set the /ect/mailname to your FQDN for the server. e.g., myserver.com

Then restart the postfix service

sudo service postfix restart

Tip: Clear the Postfix message queue: sudo postsuper -d ALL

Alternatives

Do you really need to send email on SMTP 25? Perhaps SMTPS [Secure] on 587 or 465 is a better alternative? For a CMS like Magento or WordPress there are many alternatives that are available for free, and come as a plugin and offer better end-to-end security.

~ Lead_Robot