views:

317

answers:

3

I'm calling php function mail, but it's returning false about 5% - 10% of the times, and it's driving me crazy.

I guess from the php side everything is well configured because (correct me if i'm wrong) if not the function should fail every single time.

So the question is how can i know the reason of this behavior? What can i do to debug this?

+1  A: 

I don't like PHP's build in mail for that reason. But my failure rate was below 1%.

I suggest using PEAR::Mail as described in this article. It uses an smtp-server to send emails. If an error occurs, you'll get a real error message.

tuergeist
A: 

If you retry, does the email fail again? If so, try writing out the email to a file and send it manually with sendmail to see what kind of error you get.

If you're using PHP 5.3 or later, you might try turning on mail.log.

Jeremy Stein
In some cases it fail again, in fact i retry every single mail 10 times in a loop 'for ($i=0; $i < 10; $i++){if(mail(...,...,...,...)) break;}'Even with that, i'm still have a 'failure' rate of 5%-10%
Cesar
+1  A: 

What server is this being ran on. I've had the most difficulty on Windows server, but on linux and mac I have had no issue when using sendmail, which is what both were configured to use.

woody993
I have no control on the server, all i know is the server identified itself as: Sun-ONE-Web-Server/6.1
Cesar