Search code examples
linuxemailamazon-web-servicesamazon-ec2mailx

Amazon AWS EC2 Instance Email Not Being Received


If I SSH into my instance and send email to my Gmail account:

echo "Test." | mail -r "myuser@gmail.com" -s "Subject Test" myuser@gmail.com

I'll receive the email.

However, if I do the same command but send it to my Hotmail account, I don't receive the email:

echo "Test." | mail -r "myuser@hotmail.com" -s "Subject Test" myuser@hotmail.com

What's weird is I have other EC2 instances that ARE able to email myuser@hotmail.com. I am using an Elastic IP.

What do I have to do to be able to receive email from my EC2 instance using my Hotmail account?


Solution

  • IPs in some of EC2 IP ranges are black listed by Hotmail, that explains why it succeeds on some machine. It is possible a spammer used a EC2 instance in the past whose IP was in the same blocked IP range. Your options:

    • Disassociate this elastic IP and attach another elastic IP, hoping the new IP is not in the blocked IP range.
    • Use AWS SES or Sendgrid or other 3rd party providers