I'd like to start using Amazon SES for all emails from our server. We have a few freelance designers with PHP hosting, some Django/Python web apps and also some system utilities which send emails.

So I'd like to have PHP's mail function, the command line mail command and our python apps all be able to use it, preferably without having to set them all up in their own way.

I think what I need is to have something like Postfix running on localhost and using SES for it's delivery but I don't know how to do that.

Amazon's docs state I need to setup my mail transfer agent (MTA) so that it invokes the ses-send-email.pl script. I have the script but I'm not sure how to achieve this.

Am I on the right track? If so, how can I configure Postfix to use that script?


Amazon just released SMTP access to SES. I whipped up a quick howto for it this morning: http://www.millcreeksys.com/2011/12/14/how-to-configure-your-postfix-server-to-relay-email-through-amazon-simple-email-service-ses/

  • Having no luck with sender_dependent_relayhost... all email is bypassing stunnel, any suggestions? :) – CMag Mar 27 '12 at 17:07

Here are some items copied from SES developer guide:

To integrate ses-send-email.pl with Postfix:

  1. Open the master.cf file. On many systems, this file resides in the /etc/postfix directory.
  2. Configure a new mail transport by adding the following two lines to the master.cf file, and then saving the file.

    aws-email  unix  -       n       n       -       -       pipe
      flags=R user=mailuser argv=/opt/third-party/amazon/ses-send-email.pl -r -k /opt/third-party/amazon/aws-credentials -e https://email.us-east-1.amazonaws.com -f ${sender} ${recipient}

Note the following about this example:

  • The flags line begins with at least one whitespace character.
  • The user parameter must specify a non-root user (i.e., a nonadministrative user).The user mailuser is for illustrative purposes only.
  • The ses-send-email.pl script and the credentials file reside in the /opt/third-party/amazon directory.
  • The endpoint for communicating with Amazon SES is https://email.us-east-1.amazonaws.com

You should modify these parameters as appropriate.

  1. Open the main.cf file in the same directory as master.cf and modify it as follows:

    1. Look for the default_transport line:

      • If it exists, change it so that it looks like this:

        default_transport = aws-email
      • If it doesn't exist, then add a new line with the preceding content.

    2. Save the main.cf file when you are done.
  2. Restart your Postfix server.

    /etc/init.d/postfix restart

Note that this command may not be exactly the same on your particular server. From this point on, your outgoing email is sent via Amazon SES.You can test this by sending an email message through your Postfix server, and then verifying that it arrives at its destination. If the message is not delivered, check your system's mail log for errors. On many systems, this is the /var/log/mail.log

-- I created a simple blog put all things together I tried recently in Amazon Cloud and SES. Here is the link : http://netwiser.blogspot.com/2011/02/setup-amazon-ses-to-relay-email-by.html

  • Awesome, thanks. I assume this means that configuring postfix is the right way to solve my problem. I'll give this a try and accept your answer soon. – Jake Feb 3 '11 at 22:27

Since you're hosting Python/Django apps on your server, you might find it preferable to hookup Postfix to the Python equivalent of the AWS Perl scripts. This guide has the details:


Alternatively, if you want to use the Perl scripts but found (like me) that your CPAN modules are horribly out of date, an easier route may be to install the dependencies through your operating system's package manager. E.g., on ubuntu, you can do this with:

sudo apt-get install libio-socket-ssl-perl libxml-libxml-perl

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.