Cloud Tips: Sending Email from an EC2 Instance

By George Reese
January 16, 2009 | Comments: 2

In my blog post a few weeks back on How I Ended up in the Cloud, I mentioned a number of issues we encountered moving to an EC2 infrastructure. One specific problem we encountered was sending email from inside the cloud. The reality is that you just can't reliably do it using traditional methods. You can, however, do it and do it better.

Our problem was this: we have a number of forms and automated alerts in our software that kick off emails to a variety of recipients. Our software typically contacts a Postfix service running on the local host to execute delivery. When Postfix attempts to deliver a message from the cloud, however, many (if not most) receiving agents view that mail as spam. In fact, a number of black hole lists have Amazon EC2 IP addresses black listed.

The way around this challenge is to set up an authenticated relay host with a provider outside of the cloud. Valtira and enStratus have accounts with a Twin Cities-based ISP, ipHouse, and use their server to relay email. The result is that email is handled via an encrypted medium through an authenticated account from EC2 over to ipHouse and then moves on to its final destination. Since ipHouse is a trusted entity, most places accept the mail and its thus makes it to your target.

The key here is that your use needs to be legitimate. If you are looking to follow this approach for spamming purposes, ipHouse and any other reputable vendor will quickly cut off your authenticated account. If you need to send legitimate email from EC2, however, it will meet most of your needs.

Here's how you do it:

Step 1: Create an account with an email provider

You want to make sure the email provider is a reputable provider, otherwise you risk your email not being delivered due to trust issues with the provider. In addition, the provider cannot be an entity like Google that rewrites your "Reply-to" and "From" headers (unless the address on the emails matches the account email).

You should also select a provider that supports encrypted authentication. You don't want your email account passwords going out from the cloud to your provider in plaintext.

Step 2: Configure Postfix to Relay Email

Your Postfix implementation needs to support TLS for this to work. You:

a. Make sure Postfix is accepting mail only from localhost. You don't want someone else using your authenticated account to send spam and ultimately get your account zapped.
b. Create a Postfix password database to store your email account password.
c. Setup Postfix to relay to your mail provider.
d. Start sending email.

You might also be interested in:


There is a very good email provider called Elastic Email ( which specializes in Amazon EC2 email delivery.

Anyone know of a good tutorial for how to do the above? To install postfix and set it up as described?

News Topics

Recommended for You

Got a Question?