8

I am not used to cloud hosting. Previously I would just setup an email account through cPanel, but since this is not available how would I go about doing this on a Amazon EC2 account? I am assuming I need a email server running? I installed 'postfix' on my linux instance. Now what?

2 Answers 2

6

Depending upon your requirements, you either

A) Use SNS

or

B) don't send email.

Sure, internal email will work fine, but just about everything you send should get rejected as spam unless you send from ec2-a-b-c-d.compute-1.amazonaws.com. To set up email you need matching reverse-IP mappings, not to mention SPF and DKIM. With EC2 you don't have access to the authoritative DNS sources for the IPs and therefore can't properly configure the network.

SNS isn't intended for sending mail to end users, but if you're after monitoring or workflow configuration, it'll fit your bill quite nicely.

Likely you'll want an external mailhost. I hear Rackspace has some nice options, but I've never used them myself.

Edited

I was unaware of the Amazon mail requests form: this provides another option that will let you send mail from EC2.

You'll first have to allocate and assign an Elastic IP to your mail server, since this removes the fluidity problem. Be sure to set up monitoring, since if your mail server goes down your Elastic IP will be left dangling and you have to pay per hour for unattached Elastic IPs.

Next, you'll need to set up a forward mapping to this IP from your domain: in BIND syntax for the zonefile "example.com.", that'd be

mail   IN  A  1.2.3.4

Depending upon your DNS settings (specifically, your RTTL) this may take some time to propagate. It's easiest just to wait a day, but you'll probably be safe whenever a nslookup mail.example.com returns 1.2.3.4.

You should also specify that mail to your server should be handled by mail.example.com, since the old public IP your EC2 instance had will be replaced by the new elastic IP.

Include the EIP in the form where requested, and mail.example.com as the reverse DNS.

(In BIND, the record would be entered as 4.3.2.1.in-addr.arpa. IN PTR mail.example.com.)

As the form states, it may take some time for whitelists to be updated.

Pitfalls:

EC2 hosts are not intended to be terribly stable. If you use this as a production service you should have two mail server hosts configured fully redundantly. If/when one fails, you should have the ability to automatically or at least quickly deploy a new server to replace it.

6
  • The emails are working but are indeed appearing in spam boxes. I heard you can change the "reverse DNS" settings to fix this problem?
    – John
    Jun 28, 2011 at 18:27
  • If you could change the reverse mappings, yes, this would help to solve your problem. But Amazon doesn't give access to these zone files to you because the IPs are much more fluid in a cloud environment. If you want this feature, you need a VPS or hosted mail server. Jun 28, 2011 at 18:29
  • In this link: https://aws-portal.amazon.com/gp/aws/html-forms-controller/contactus/ec2-email-limit-rdns-request what would I enter in the revere DNS fields? Thanks for your help!
    – John
    Jun 28, 2011 at 18:34
  • Heh, didn't know they provided that option :) Editing my answer accordingly. Jun 28, 2011 at 18:36
  • SNS / SES ? Don't mix up these .
    – Raptor
    May 27, 2016 at 3:14
2

These days, you may also be interested in:

Amazon Simple Email Service (Amazon SES)

http://aws.amazon.com/ses/

If you are an Amazon EC2 user, you can get started with Amazon SES for free. You can send 2,000 messages for free each day when you call Amazon SES from an Amazon EC2 instance directly or through AWS Elastic Beanstalk. Many applications are able to operate entirely within this free tier limit.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .