Manual VPS - PHP mail() and PEAR smtp taking a long time, sending three emails

I was running a website on a shared hosting account.  Part of this website involved sending a lot of messages via PHP mail().  Unfortunately, all shared hosting providers I could find had a cap on how many emails could be sent per hour.

So, I decided to get a VPS.  I am cheap, so I thought I would get an unmanaged one with cpanel.  Everything is fine and dandy, I have everything up and running.  The only problem I have, is that every message sent by php mail takes about 30 seconds to send.  Not only that, but it sends it three times.  The same thing happens when I send via the PEAR SMTP package.  Takes about 30 seconds, and sends three times.

It could be a DNS issue, I had no idea how to set it up, so I guessed:
A-type: @
MX entry: @ - Mailer-server:

Any ideas?  Any other info you need?
Who is Participating?
pete-mcpeteyConnect With a Mentor Commented:
Your asking 3 different questions. Please open a new thread for cPanel DNS Resolvers and for Mail Queuing. I don't believe these 3 problems are related.
rom109Author Commented:
In case it is helpful, I am running a Linux, CentOS box with Cpanel:
/etc/hosts: localhost.localdomain localhost
# Auto-generated hostname. Please do not remove this comment. web  server1

You will want to determine if this is an issue with the mail server (exim) or with PHP/Apache.
Can you start by sending a unique message, and then displaying the mail logs? For example, if you put "" as the recipient, you can run this SSH command to find the relevant logs. Thanks.

after submitting the form, grep for the email address you used:
# cat /var/log/maillog | grep ""
(please let us know what results you receive).
# cat /var/log/exim_mainlog | grep ""

Let us know the results of the logs (if there are 3 entries, most likely this is PHP submitting the form 3 times).
Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

Also, what email client are you using? For example, there was a problem with Outlook duplicating the message. If you use the webmail to check the mail, does that also show triplicate messages?
rom109Author Commented:
Pete, you were right, the triplicate messages were just an outlook bug that has since been fixed.  But the long wait on sendmail is still a problem.

When I use php mail() to send a message to "", /var/log/maillog has no mention of, and exim_mainlog just says "2011-02-16 12:27:41 1Ppm5r-0008IF-7Q ** R=fail_remote_domains: The mail server could not deliver mail to  The account or domain may not exist, they may be blacklisted, or missing the proper dns entries."

And it took 27 seconds to send.  Could I just have a slow server?  Is that a normal wait time?
rom109Author Commented:
I noticed also that I keep changing /etc/resolv.conf to my nameservers, but they keep changing back to and  Could this slow things down?  How can I  get it to stay as my nameservers?
rom109Author Commented:
Also when I SMTP to a different server (that sends fine on its own) it still takes about 30 seconds.  So perhaps the problem isn't sendmail, but an email setting somewhere?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.