The Montoya Herald — ChristianMontoya.com
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.
Use the comment form to leave a comment here.
Sorry, comments for this entry are closed at this time.