The Montoya Herald, a weblog about Blueprint, jQuery, design, music and life, publishing on the web since September 2005. Written by Christian Montoya: developer, designer and entrepreneur.

The Montoya Herald — ChristianMontoya.com

Search

Buy My DVD!

Like What I Do?

My Amazon.com Wish List

On this domain

Elsewhere

Making sendmail work on CentOS 5.2

Posted on March 6, 2010.

I'm writing this post to keep track of the steps I had to take to fix what seemed like an impossible problem on my CentOS powered web servers.

Recently I had to wade into dirty waters and set up a service that would send daily emails to a set of addresses that had opted-in for these updates. On initial testing, I found that it took over 60 seconds to send an email from PHP. Since I don't mess with the command line much, I was working with sendmail, and needed to figure out what was causing this huge delay. For quite some time, I thought there was some fundamental problem with CentOS or sendmail that was to blame. It turns out that it was just a DNS problem. Here are the DNS settings I had to enter to make sure that DNS checks would go through properly and make sending emails a sub-second process (these settings apply to a server with the FQDN 'MyServer' under the address 'myserver.mydomain.com':

File /etc/nsswitch.conf had to have a line exactly like this:

hosts: files dns

File /etc/resolv.conf had to have a line exactly like this:

domain myserver.mydomain.com

Finally, file /etc/hosts needed these lines:

127.0.0.1       localhost localhost.localdomain loopback me
127.0.0.1       MyServer myserver.mydomain.com

And that's it! With the right DNS settings in place, email sending took less than half a second… as it should have.

No Comments Yet

Use the comment form to leave a comment here.

Sorry, comments for this entry are closed at this time.