0

I am new to php. I have used a mail() function in order to send mails. I know for a fact that the mail function is used just for queuing up the mail to the server and further has no hand in it. I wanted to ask whether there is any method of knowing as to what was the error if the mail has not been queued to be sent on the server.(Sending of the mail being an entirely different problem).

Considering my code to be:

if(mail($to,$subject,$content,$headers))

{
    echo"Sent";
}
else
{
    print_r(error_get_last());
    echo"not sent";
}

I have seen this question but the answer doesn't solve my problem.

Thanks in advance and apologies if the question appears to be baseless to you.

Community
  • 1
  • 1
YashVj
  • 63
  • 10
  • Why doesn't that answer solve your problem? It looks like it's the only way to do what you want. If the `mail()` function succeeds, it means the message was queued successfully. If it can't be delivered for some reason (like an incorrect account name), PHP can't detect that. – Barmar Jul 05 '14 at 08:03
  • @Barmar, i tried that code but it just gives a blank. No reason at all. – YashVj Jul 05 '14 at 08:48
  • Is the `mail()` function really getting an error? Is there anything in the PHP log? – Barmar Jul 05 '14 at 08:50
  • Sir, i have edited my else statement above, "not sent" is getting printed but no error message! – YashVj Jul 05 '14 at 08:54

0 Answers0