I generally dread working with email no matter what system it is on! Here I am going to discuss some useful tips for debugging an email system on a Linux server. I am using an Amazon Linux AMI with Centos, but the process is similar for any Linux server you might have. Below I will discuss how to check error files and how to avoid sending email to spam or junk folders.
Having Trouble Sending Email?
If you’re emails are not getting through and you don’t know why, check your server’s log files. Below I’ll show you how to find mist email related error logs. They can normally be found in /var/spool/mail/username which on an Amazon Linux distro would be either:
It is important to know that in the above context, username, root and ec2-user are files, NOT directories. To open one of those files, navigate to /var/spool/mail like:
To open root file with your Linux command line text editor, type:
sudo vi root
…and check the last errors to see the most recent.
TIP: use [shift]+g to skip to the last line of the file using VI editor.
How to Avoid Sending eMail to Spam or Junk Mail folders
Amazon EC2, SES and sendmail environment
- When using the -f parameter with /usr/sbin/sendmail command, the from email I used WAS VERIFIED in my Amazon SES console.
- I did convert sendmail on the EC2 server to use SES as described in the following SES documentation: http://docs.aws.amazon.com/ses/latest/DeveloperGuide/sendmail.html
The following command line commands sent emails to my In Box:
- /usr/sbin/sendmail firstname.lastname@example.org
- sudo mail email@example.com
- mail firstname.lastname@example.org
The following command line commands sent emails to my Spam:
- /usr/sbin/sendmail -f SESverified@email.com email@example.com
- sudo /usr/sbin/sendmail -f SESverified@email.com firstname.lastname@example.org
- sudo /usr/sbin/sendmail email@example.com
In the above examples, I didn’t use parameters for subject, CC or BCC because they don’t seem to make any difference. Only using sendmail, sudo and the -f parameter made a difference to determine if the emails were delivered to my in box or spam folder.
As you can see from the above spam tests, the best way to avoid spam is to:
- Avoid using the -f parameter even with an SES verified email address.
- While /usr/sbin/sendmail method did work when avoiding both the -f param and the sudo command, the mail method worked with or without sudo.
- Either use /usr/sbin/sendmail without -f parameter and without using sudo, or use mail for the best chances of your email getting through to your recipients in boxes.