The sendmail 60 second delay

Joeri Poesen //

Environment: ubuntu server on a slicehost VPS 512MB slice, nginx/rails/mysql stack, clean sendmail without config changes

Problem: mail sent through ActionMailer takes 60 seconds (or times out), same mail is delivered multiple times until the original request times out, resulting in a server 504 error.

Steps to reproduce: make a sample text file with "hello world" and send it to yourself. Sendmail will wait for 60 seconds.

<br></br>sendmail -v <a href="/cdn-cgi/l/email-protection#6e17011b2e17011b1c1d071a0b400d0103"><span class="__cf_email__" data-cfemail="40392f3500392f3532332934256e232f2d">[email protected]</span></a> < sample.msg<br></br>

Cause: sendmail always waits for 60 seconds when your hostname is not a FQHN (fully qualified host name). In my case, it was simply ortega. Sendmail will asume a temporary DNS lookup failure and try again (while actually sending out the mail, strangely enough).

Solution:
* first, in /etc/hostname, change your hostname from whatever to a FQDN like whatever.one-of-your-hosted-domain-names.com
* then, in /etc/hosts, add a host entry like:

99.123.45.67 whatever.mysite.com

Reboot and try to send a mail to yourself again. Sendmail wil not delay at all. Thank you, googleweb. This shit only took me 3 hours to figure out.