Search code examples
phpsendmaillamp

determine true mail sent status (PHP mail())


I am using inbuilt support of sending mails in php.

$status=mail($to,$subject,$message,$headers,"-f $from");

I am on LAMP server and we use sendmail Unix utility. php mail() returns true status if it has handed over the mail to sendmail so we can not be sure that whether a mail has been sent successfully of not. Now what I want is to make some socket connection between php and sendmail so that I can get the "True status" whether mail has been sent or not.

I am very new for PHP. This is the part of the first problem which I am solving in PHP. I Goggled but I am not getting exactly how to proceed further. Guide me how can I get true status whether a mail has been sent or not at PHP end?


Solution

  • Option 1: Socket connection: read the RFC, then write a standards-compliant SMTP client program. [don't even bother unless you want to throw a few weeks of your life away]

    Option 2: Use PHPmailer or SwiftMailer or one of the other bazillion mailing libraries that have already written a standards-compliant SMTP client that will actually tell you if the mail was successfully sent or not.