My EC2 instance's email is being spam blocked by gmail

Solution 1:

EC2 now lets you do configurable reverse DNS, which is a big help if you're trying to send out email from an EC2 instance. Have a look at this AWS blog post for more details.

Solution 2:

Amazon has now released their own email service. Amazon SES. Thats your best bet for just sending mail.

If you want more detailed statistics and insight into your mail like tracking opens and clicks you could use a third party SMTP server, the old favourite is AuthSMTP, if you want something a little more modern and cheaper try Elastic Email (

Solution 3:

Generally EC2 IPs are banned and blacklisted almost in all spam filtering service due to an unfortunate thing that spammers like to buy instances and use it for spamming.

The only thing what you could about it to use elastic IP and ask the common spam filtering services to remove your /32s.

Other solution would be to use some SMTP proxy service somewhere.

Solution 4:

This is what worked for me after some trial and error with the EC2 instances

  1. Using /sbin/postfix instead of /sbin/sendmail
  2. I set my mailserver's hostname in /etc/postfix/ like this: myhostname=www.your.tld (change www.your.tld to your server's name)

  3. I set a Sender Policy Framework (SPF) record up in my DNS like this: @ IN TXT "v=spf1 a +all"

  4. I set a DKIM record up in my DNS like this: _adsp._domainkey.your.tld IN TXT "dkim=unknown" (Change your.tld to your domain name eg.

  5. I requested reverse-DNS be setup on my Elastic IPs to resolve to my domain using the AWS contact form at

My web application's mails don't get routed to spam by GMail anymore. Not until they dream up some new anti-EC2 -err anti-spam cock and bull anyway!

Solution 5:

In my opinion its a bad idea to have a +all in SPF record. +all means pass all, as good as not having an SPF record. You should change it to something like

@ IN TXT "v=spf1 +a +mx ip4: ip4: -all"

+a means allow all ips which have an A record in the DNS
+mx means allow all ips with an MX record in the DNS
ip4:n.n.n.n means allow this IP to send emails
-all means do not allow anything else to send emails from this domain. The rules are checked from left to right. hence -all in the end will disallow anything that did not satisfy the earlier rules



should be changed to