How to relay email to different mail server using Postfix On AWS EC2 instance.

aws-logoBy default Amazon limits the amount of email you can send from an instance. You can ask AWS to remove that limitation using this page. This form also allows you to set up the reverse DNS. If your application have a functionality to send emails then you will be in trouble if you chose AWS for the application hosting. But AWS is a good cloud platform to host web applications. So, how to resolve the emil issue? To resolve this issue you need to configure postfix to relay email to different mail servers. In this article I will show you how to relay emails to different mail server using postfix. In this example I will use Sendgrid as my smtp provider.

First we need to install postfix on our server:

Again we need to install some dependency modules:

After completing installation we have to modify the postfix config file /etc/postfix/ and add the below lines to it:

Now we need to store our Sendgrid username and Password

/etc/postfix/sasl_passwd must be owned by root, and no one else should have read access to that file, so we do this:

After that, need to convert /etc/postfix/sasl_passwd into a format that Postfix can understand:

This will create the file /etc/postfix/sasl_passwd.db. And then we need to restart Postfix for our configurations to take effect:

We are done!! Now our mail should passing on to

The following two tabs change content below.

Tapas Mishra

Sr. Engineer (DevOps)
Loves to work on Opensource products. Having experience on Linux environment. Knowledge on Public cloud services like AWS, Rackspace, DigitalOcean, Linode. Please don't hesitate to give a comment on the posts. Your comments are my strength.

Leave a Reply