Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2011-02-15
7
1,277 Views
Last Modified: 2012-05-11
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: @ smsalertsonline.com 174.36.99.28
A-type: www.smsalertsonline.com 174.36.99.28
MX entry: @ smsalertsonline.com - Mailer-server: smsalertsonline.com

Any ideas?  Any other info you need?
0
Comment
Question by:rom109
  • 4
  • 3
7 Comments
 

Author Comment

by:rom109
ID: 34899749
In case it is helpful, I am running a Linux, CentOS box with Cpanel:
/etc/hosts:
127.0.0.1 localhost.localdomain localhost server1.smsalertsonline.com
# Auto-generated hostname. Please do not remove this comment.
174.36.99.28 server1.smsalertsonline.com web  server1 smsalertsonline.com

/etc/resolv.conf:
nameserver 4.2.2.1
nameserver 4.2.2.2
0
 
LVL 3

Expert Comment

by:pete-mcpetey
ID: 34908499
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 "foo@bar.com" 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 "foo@bar.com"
(please let us know what results you receive).
# cat /var/log/exim_mainlog | grep "foo@bar.com"

Let us know the results of the logs (if there are 3 entries, most likely this is PHP submitting the form 3 times).
0
 
LVL 3

Expert Comment

by:pete-mcpetey
ID: 34908529
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?

http://support.microsoft.com/kb/885870
0
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 

Author Comment

by:rom109
ID: 34909479
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 "foo@bar.com", /var/log/maillog has no mention of foo@bar.com, and exim_mainlog just says "2011-02-16 12:27:41 1Ppm5r-0008IF-7Q ** foo@bar.com R=fail_remote_domains: The mail server could not deliver mail to foo@bar.com.  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?
0
 

Author Comment

by:rom109
ID: 34909552
I noticed also that I keep changing /etc/resolv.conf to my nameservers, but they keep changing back to 4.2.2.1 and 4.2.2.2.  Could this slow things down?  How can I  get it to stay as my nameservers?
0
 

Author Comment

by:rom109
ID: 34910762
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?
0
 
LVL 3

Accepted Solution

by:
pete-mcpetey earned 500 total points
ID: 34911113
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.
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
move expression web site to a new server 13 53
How to obtain the string from a PHP StdObject ? 6 33
PHP Echo with auto submit 8 28
Accessing specific element - DOM PHP HTML 8 34
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question