The sendmail 60 second delay

2007-04-02 / jpoesen

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.


sendmail -v [email protected] < sample.msg

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.