Install postfix with
apt-get update && apt-get install postfix libsasl2-modules -y
Update postfix config with
sed -i "s/default_transport = error/# default_transport = error/g" /etc/postfix/main.cf sed -i "s/relay_transport = error/# relay_transport = error/g" /etc/postfix/main.cf sed -i "s/relayhost =/# relayhost =/g" /etc/postfix/main.cf
Edit
vi /etc/postfix/main.cf
Add to end of the file
relayhost = [SMTP_SERVER_NAME]:587 smtp_tls_security_level = encrypt smtp_sasl_auth_enable = yes smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd smtp_sasl_security_options = noanonymous
In the above, replace SMTP_SERVER_NAME with your Amazon SES mail server, for example “email-smtp.us-east-1.amazonaws.com”, you can see it in your Amazon SES console.
Run
echo "[SMTP_SERVER_NAME]:587 SMTP_USERNAME:SMTP_PASSWORD" > /etc/postfix/sasl_passwd
Replace SMTP_SERVER_NAME, SMTP_USERNAME and SMTP_PASSWORD with your actual credentials.
Now run
postmap /etc/postfix/sasl_passwd
Restart postfix
service postfix restart
You can test mail working with
echo "test" | mail -r you@SES_VERIFIED_DOMAIN -s "test" [email protected]
For sending from Apache, you may need to set myorigin in postfix confgiration with your veirfied domain. This can be done by editing
vi /etc/mailname
You can verify myorgin with
root@ip-172-31-30-228:~# postconf | grep myorigin append_at_myorigin = yes myorigin = /etc/mailname root@ip-172-31-30-228:~#
Sending Mail from Amazon EC2
When sending email from Amazon EC2, it rejected with
Aug 28 17:20:59 ip-172-31-11-238 postfix/smtp[27260]: 1BB10831A0: to=, relay=email-smtp.us-east-1.amazonaws.com[23.23.196.20]:587, delay=2.9, delays=0.02/0.03/1.7/1.2, dsn=5.0.0, status=bounced (host email-smtp.us-east-1.amazonaws.com[23.23.196.20] said: 554 Message rejected: Email address is not verified. The following identities failed the check in region US-EAST-1: [email protected] (in reply to end of DATA command))
Problem is solved by editing
vi /etc/postfix/main.cf
Find
myhostname = ip-172-31-28-58.ap-southeast-2.compute.internal
Replace with
myhostname = AWS_VERIFIED_DOMAIN_HERE
Leave a Reply