Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 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?

share|improve this question
up vote 8 down vote accepted

Amazon just released SMTP access to SES. I whipped up a quick howto for it this morning:

share|improve this answer
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 with Postfix:

  1. Open the 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 file, and then saving the file.

    aws-email  unix  -       n       n       -       -       pipe
      flags=R user=mailuser argv=/opt/third-party/amazon/ -r -k /opt/third-party/amazon/aws-credentials -e -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 script and the credentials file reside in the /opt/third-party/amazon directory.
  • The endpoint for communicating with Amazon SES is

You should modify these parameters as appropriate.

  1. Open the file in the same directory as 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 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 :

share|improve this answer
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
share|improve this answer
Thanks, installing these dependencies rescued me! – Matt Williamson Dec 2 '11 at 3:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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