Integrating Amazon SES with Postfix

Integrating Amazon SES with Postfix

In this blog post, we have documented how we can use AWS SES with postfix in a Linux system for email services.

Amazon SES : – Amazon Simple Email Service (Amazon SES) is an email platform that provides an easy way for you to send and receive email using your own email addresses and domains.

Postfix: – Postfix is an OpenSource Mail Transfer Agent, that can be used to route and deliver emails.

Prerequisites: – 
1. sender email domain name.
2. AWS Account with SES and Ec2, route53 access.
3. uninstall Sendmail, of already installed.
4. public IP in an instance with outbound network allowed.

Verify Domain in aws ses.

login to AWS and open SES, it will open  SES Home Page, click on “Verify a new Domain”

Enter your Domain name, in my case its “”

click on Generate DKIM Settings, now click on “verify this domain”

it will open a new window with CNAME and TXT record for domain verification.

create TXT and CNAME entry against your domain as mentioned in the above picture.

Note: – if your domain hosted in aws route 53 it will automatically detect and give a click image “use route 53”, it will automatically create DNS entries.

Now click on “SMTP Setting”.

Now generate SMTP credentials, click on “Create My SMTP Credentials”.

save Access and secret keys.

Configure Postfix to use SES.

Now install postfix in your Ec2 machine, in the case I have taken ubuntu.

 $sudo apt-get update
 $sudo apt-get install postfix

Configuring Postfix

1. In server terminal type the following command:

$sudo postconf -e "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_security_level = encrypt" \
"smtp_tls_note_starttls_offer = yes"


Note: – replace with your appropriate aws region

Region Endpoints for SES

US East (N. Virginia) : -
US West (Oregon) : -
EU (Ireland) : -

2. open the file “/etc/postfix/” , search for following entry “-o smtp_fallback_relay=”
if the entry is present, comment it out by placing a # (hash) character at the beginning of the line. Save and close the file.

3. create a sasl_passwd file

$sudo vim /etc/postfix/sasl_passwd

Add the following line


Note: Replace SMTPUSERNAME: SMTPPASSWORD with your SMTP Access and Secret key.

4. create a hashmap database containing SMTP credentials

$sudo postmap hash:/etc/postfix/sasl_passwd

5. change the ownership and permission of sasl_passwd and sasl_passwd.db

$sudo chown root:root /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db
$sudo chmod 0600 /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db

6. Tell Postfix where to find the CA certificate (needed to verify the Amazon SES server certificate).

$sudo postconf -e 'smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt'

7 Restart postfix

 $sudo service postfix restart

8 send a test email by type this in the terminal, after final line type single period (.) with no other content.

$sendmail -f [email protected] [email protected]
From: Sender Name [email protected]
Subject: Amazon SES test mail
test mail form ses.

check email in your inbox, Happy Email sending!!

3 Replies to “Integrating Amazon SES with Postfix”

Leave a Reply to this article Cancel reply

Your email address will not be published. Required fields are marked *