Search code examples
amazon-ec2mailx

Unable to send email from AWS EC2 instance using mailx


I want to email myself an error log stored on AWS EC2 instance to help me troubleshoot an issue I am having while trying to remote desktop to the machine. This is a one time thing - I am not going to use EC2 to send emails reguarly from a web app etc. Reading this link it says:

Q: Are there any limitations in sending email from EC2 instances?

Yes. In order to maintain the quality of EC2 addresses for sending email, we enforce default limits on the amount of email that can be sent from EC2 accounts. If you wish to send larger amounts of email from EC2, you can apply to have these limits removed from your account by filling out this form.

So this means I should be able to send a few emails without any problem. I tried emailing myself the error log like this:

cat log.txt | sudo mailx me@yahoo.com

It does not give any error but the file is never delivered. I think its never send out. How can I troubleshoot this? I am not familiar with unix. Reading around a bit mailq shows me this:

-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient-------
6295B488F5    37616 Wed Apr  1 02:10:30  root@ip-xxx-xx-x-xx.us-west-2.compute.internal   a@yahoo.com

I don't know what to do beyond this.

EDIT: Its funny. I did get the messages delivered to my inbox but it was only after about 2 days.


Solution

  • If you have ssh access to the box,just use scp to get the file. E.g., from OSX command line:

    scp -i your.pem ubuntu@ec2-1-2-3-4.compute-1.amazonaws.com:your_file your_file
    

    This is for "ubuntu" login, with "your_file" in home directory, saved to same name locally. I guess there are GUI versions also, e.g., I used to use Putty on Windows.