Amazon EC2 Email Setup for Ubuntu Server

If you want to setup an email service on your amazon ec2 instance you have to use Amazon SES.

The use of an own mail service is not possible because amazon does not want his servers to be misused for SPAM sendings.

To setup e-mail for your amazon ec2 instance follow these guides instead:

Integrating Amazon SES with Postfix
Amazon SES SMTP Issues

After that check your config by using sendmail and have a look at the log file

tail /var/log/mail.log

If you receive the following error for your amazon ec2 instance postfix mail setup (/var/log/mail.log):

postfix/smtp[3548]: F2A1845132: to=<xxxx@xxxx.de>, relay=none, delay=473, delays=473/0.02/0/0, dsn=4.4.3, status=deferred (Host or domain name not found. Name service error for name=email-smtp.eu-west-1.amazonaws.com type=AAAA: Host not found, try again)

postfix/smtp[3548]: F2A1845132: to=<xxxx@xxxx.de>, relay=none, delay=473, delays=473/0.02/0/0, dsn=4.4.3, status=deferred (Host or domain name not found. Name service error for name=email-smtp.us-east-1.amazonaws.com type=AAAA: Host not found, try again)

postfix/smtp[3548]: F2A1845132: to=<xxxx@xxxx.de>, relay=none, delay=473, delays=473/0.02/0/0, dsn=4.4.3, status=deferred (Host or domain name not found. Name service error for name=email-smtp.us-west-2.amazonaws.com type=AAAA: Host not found, try again)


then you have to disable ipv6 in your /etc/postfix/main.cf config

relayhost = [email-smtp.eu-west-1.amazonaws.com]:25
smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noanonymous
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_use_tls = yes
smtp_tls_security_level = encrypt
smtp_tls_note_starttls_offer = yes
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
inet_protocols = ipv4

Important is the last line (number 9)

If the domain still can not be found you have to update your resolv.conf for postfix:

sudo rm /var/spool/postfix/etc/resolv.conf
sudo ln -s /etc/resolv.conf /var/spool/postfix/etc/resolv.conf

Restart the postfix service

sudo service postfix restart

Leave a Reply

Your email address will not be published.