Setting Mail Server Hostname
The Situation
You send email from your application. You don’t want to end up in someone’s spam box.
The Fix
This is not always an easy problem to solve. We’ll start with the easiest step.
Sendmail
On your server, edit /etc/hosts. The last line should have the public IP address of your server. Add the domain name that you send mail from in front of the railsmachina name, like this:
<your public ip> mail.yourdomain.com your_account.railsmachina.com
Then restart sendmail:
sudo /sbin/service sendmail restart
Postfix
Edit the myhostname variable in /etc/postfix/main.cf:
myhostname = mail.somedomain.com
Then restart postfix:
sudo /sbin/service postfix restart
Testing your setup
From your server, you can test by running
telnet localhost 25
The mail server should identify itself as
mail.yourdomain.com.
If you still have problems with email being marked as spam, you can create SPF records in your DNS, or you can set up DKIM.
