Sendmail is slow to send mail

October 7, 2013 28.1k 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
6 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
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

Have another answer? Share your knowledge.