Click to See Complete Forum and Search --> : php mail() function suddenly not working on any site
BWWebDesigns
12-19-2006, 09:39 PM
Hi there
maybe a little off topic but was wondering if anyone could offer some explanations why the php mail() function on all of my sites has stopped working at all
i have successfully used it for years and now its not working for the past few hours
i know its probably a problem at the hosts end but just wodnered what might have happened to cause this
sneakyimp
12-20-2006, 12:33 AM
php mail() works by contacting a mail server and attempting to hand off the mail message to it. in some cases, the mail server runs on the web server. in other cases, php will try to connect to some other machine to send it.
in either case, php's mail() function returns TRUE if php manages to get a successful response from the responsible mail server and the other mail server agrees to put it in the mail queue.
when you say it 'doesn't work' that could mean a few different things
1) mail() is returning a value of false meaning php can't successfully hand off mail delivery to some other device
2) mail is returning true and then the mail never gets sent
3) mail is returning true, the mail gets sent, and it never arrives
you should be able to detect case 1:
mail(blah, blah, blah)
OR DIE('MAIL FAILED TO SEND...RETURNED FALSE');
case 2 is trickier...you'll need to contact your sysadmin and say WHY IS MY MAIL NOT GETTING SENT? but it's pretty hard to even find out when that happens. it involves looking at the mail log. if you see your sent mails recorded there in the mail server's log you should have some idea of what is up.
case 3: really tough. it's not about you but about how your server is set up and what sort of mail filter the target email domain is (hotmail has been giving me trouble lately). in that case, you have to contact them and ask what the story is.
BWWebDesigns
12-20-2006, 12:57 AM
yeah its all working nowa nd some mails i tested finally got sent so the problem must have just been a delay of some sort
sneakyimp
12-20-2006, 03:04 AM
if you have a mail account on your local server, that usually gets through right away.