21 June 2005

getting Sendmail to send fast

Just incase I forget again, Id better document this down.

Configuring sendmail can be quite convoluted. We had to redirect some emails and we just hacked up a linux box with sendmail on it to do the redirection. Unfortunately for some strange reason, mail delivery was really slow, so the web-app which sent the emails started timing-out.

On further investigation, an email will go through, but each time it logs onto the mail server it takes ages (10secs) to start the communication.
telnet smtpserver 25

First thing of course was to make sure that the server was Queueing the emails, and sending them in the background. I used webmin to check that this particular Sendmail Option was set.
That was set; no problem. Then I did a telnet to the host, and sure enough the ESMTP prompt only appeared 10 seconds later.

Googling brought about several pages on identd which we should set to 0s, as the timeout for identifying was by default 90seconds. However I noticed that the FEATURE for this sendmail option was set to 0secs. So that wasnt this problem.

I checked and double checked the host file so that the server was correctly defined with the appropriate IPs, but this shouldnt matter, as when I 'telnet localhost 25', the SMTP prompt appears instantaneously.

Then there was something about bypassing DNS lookups with this 'feature':
FEATURE(`accept_unresolvable_domains')

I plugged it in, recompiled the sendmail.cf, and true enough, remote sending was real quick. However its not acceptable for this servers configuration, as spammers can use my server to relay junk. So the way around it is to make sure that the remote sender is resolvable. And that is to make sure that they are listed in the host file, or better yet, in the local DNS.

And thats all to it! Add an entry of the sending machine in the local DNS server, which your sendmail server looks up and the IP can be resolved to a domain pronto, which means fast email sending...

What a roundabout way of configuring emails... but darn satisfying when done right.