Php mail() sometimes takes 60 seconds!


#1

Hey everyone,

I made a simple contact form for the footer of a website, nothing fancy - just verifies a valid email address, filters out any messages with URLS, and then passes it off to php’s mail() function.

When I first set it up, it worked great - sends immediately. In the last few months I’ve been noticing a problem where it will take 60 seconds to work. It will still work, but it will take 60 seconds.

I added some debugging and the “thank you for contacting us” page will take 60.0000xxx seconds to load when this problem happens.

Any ideas?

FWIW, My site is running PHP 5.3.x FastCGI with Extra Security enabled and you can test it out at http://therevox.com

Thanks,
Mike


#2

I noticed that your webpage took a long time to load when I clicked the link, in fact my browser timed out the first time before the first byte. Second try it still took 90 seconds. I suspect the problem is THIS one.

I’m not sure what you mean when you say it takes 60 seconds to send, if it does simply mean you are waiting 60 seconds for the confirmation page, then that’s probably part of the above apache issue, and not actually a problem related to the fact you are sending an email.


#3

Thanks LakeRat,
I was going to post that as a whole other issue, in case they weren’t related. But it seems they both happen at the same time… as you said, occasionally the site will time-out completely.

Looks like the thread you linked to might be the problem… but it doesn’t seem like there’s a solution to be had in there??


#4

Open a ticket and ask support to check your apache instance. They will probably come back and tell you that they cleared some hung processes and restarted apache and that seemed to clear the problem. If the problem repeats quickly ask to be moved to a new apache instance.

I’m sending you an email via the forum as well.


#5

I put up two versions of the same webpage, one uses PHP (just for includes) and one doesn’t use PHP at all. The PHP page will occasionally hang for 20-60 seconds before sending the first byte… but the flat .html version will load normal speed.

Watching top through SSH, it takes 30 seconds from the intial call to the website to even see php53.cgi pop up, and then from there another 20-30 seconds before the page even loads. What the hell…