Sendmail is slow to send mail

Posted October 7, 2013 89.7k views
I noticed that our Rails app gets error when attempting to create a user and it narrowed down to sending a registration email. When I tried to manually test it it turned out that mail actually goes out but with huge delay. It takes 1 minute to process. time echo test | sendmail real 1m0.170s user 0m0.008s sys 0m0.004s

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
7 answers
Hi Jurgen,

If you check your /var/log/mail.log you will probably find something like this: My unqualified host name (localhost) unknown; sleeping for retry. This is because sendmail requires "hostname" to be a fully qualified domain name.

update your "/etc/hosts" file: nano /etc/hosts
to look like this: localhost.localdomain localhost yourhostname

boom, fast sendmail.
Have you restarted the process?
sudo service sendmail restart

You are my hero !!! changing the hosts did the magic !!!

If my droplet is for hosting several web sites via virtualhosts instead of a single domain, does it matter what I use for the fully-qualified domain name in /etc/hosts for the purposes of using sendmail?
@Gary: No, as long as it's a FQDN and matches your IP address's PTR record, you're fine.

@oliversimon I’m a little new to server management, so pardon me if the questions sound a little stupid, but here goes:

1) When you wrote “localhost.localdomain” and “localhost”, those were as is, and not meant to be replaced with anything, correct?

2) my mail.log output showed the following:
“unable to qualify my domain name (pokemon-nyc1) – using short name”
Does the solution you provided still apply?

3) In the hosts file, I have an existing entry for: pokemon-nyc1 pokemon-nyc1

Am I correct in assuming that the “yourhostname” is, in this case, ‘pokemon-nyc1’ ? Should the new line then replace the line already existing in the system?

Try disable IPv6 for whom the first solution didn’t work