Configure Postfix to Relay to Amazon SES SMTP Server

Tags: April 27, 2016 6:55 AM


Configure internal Postfix installation to relay email to Amazon SES SMTP server.


Make sure you have done everything that Amazon SES requires you before you're able to send email using Amazon SES. After that you can start to proceed steps below.

1. Install Postfix

$ sudo apt-get install postfix libsasl2-modules

2. Configure SMTP Credential

Make sure you already have Amazon SES username and secret key. Now we need to add the credential into postfix lookup table.
$ sudo cat > /etc/postfix/sasl_passwd
$ sudo chmod 0600 /etc/postfix/sasl_passwd
You may change the smtp server according region where you setup the Amazon SES. Now update the postfix lookup table.
$ sudo postmap /etc/postfix/sasl_passwd

3. Edit /etc/postfix/main.cnf

Put the following lines to the /etc/postfix/main.cnf.
relayhost = []:587

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_CAfile = /etc/ssl/certs/ca-certificates.crt
Then restart postfix.
$ sudo service postfix restart

4. Test the Configuration

Try to sending an email to some address. We will use telnet command to send the email.
$ telnet localhost 25
Trying ::1...
Connected to localhost.
Escape character is '^]'.
220 97e02a815796 ESMTP Postfix (Ubuntu)
HELO localhost              
250 97e02a815796
250 2.1.0 Ok
250 2.1.5 Ok
354 End data with <CR><LF>.<CR><LF>
Subject: Testing Amazon SES Relay

This should be arrive in your inbox :)
250 2.0.0 Ok: queued as 8093B90
telnet> quit
Make sure that is verified and permitted to send email on your Amazon SES dashboard console.


Share on Facebook Twitter


Post a Comment