When action mailer fails to deliver to Hotmail/Outlook email accounts…
A short note on sending mail from a Rails application ( action_mailer ) to a Microsoft Hotmail account, but the email never arrives in Hotmail/Outlook.
After investigation, it looks like Hotmail probably only likes one email address per origin / server IP address. If you send an email from the same server but change the email address, then hotmail will silently block it. You wont find it in your spam folder, and adding it to your Safe Sender whitelist wont help either. It is gone without trace.
In our case we had Devise configured to send registration mail from ‘firstname.lastname@example.org’, while email notifications were configured to send notifcation mail from ‘email@example.com’.
Once we changed both configurations to ‘firstname.lastname@example.org’, it appears to now work fine, and the emails arrive as expected in the Hotmail inbox.
email from EC2 getting marked as spam
This is a large topic. Here is a checklist of topics to consider:
Consider using Amazon SES if you arent using anything yet: https://www.sitepoint.com/deliver-the-mail-with-amazon-ses-and-rails/ Free for sending up to 62,000 emails per month and receiving up to 1000 per month.
Set up Reverse DNS for Elastic IPs https://aws.amazon.com/blogs/aws/reverse-dns-for-ec2s-elastic-ip-addresses/ requested reverse-DNS be setup on my Elastic IPs to resolve to my domain using the AWS contact form at https://aws-portal.amazon.com/gp/aws/html-forms-controller/contactus/ec2-email-limit-rdns-request
fill out this form and include your Elastic IP addresses, your IP addresses will not be listed on the blacklists (after a couple of days) unless you actually start spamming from them.
By default, EC2 IP addresses are greylisted on most spam lists due to their dynamic nature. Submitting the request above will make it so your IP addresses aren’t grey listed.
Dynamic IP When setting up something like an email server you need to ensure to attach an elastic IP address to the EC2 instance as this remains statically assigned to your instance as long as you have it assigned whereas the IP address automatically assigned is a dynamic address and can be changed at any time by AWS with or without notice.
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. example.com) DKIM and DMARC are important as they are used by email servers receiving email from your domain to ensure that the email is a genuine email from your domain and hasn’t been sent as spam through another service or network. Explaining all the in’s and out’s of DKIM and DMARC is beyond the scope of this answer but doing a quick Google search shows a large number of resources out there on how to setup DKIM, DMARC, and SPF for your chosen email server.
Set a Sender Policy Framework (SPF) record up in my DNS like this: @ IN TXT “v=spf1 a +all”