Is there a way to get the dsn status of an email set with postfix, with php mail function or any other library ? . I could parse the log for the id and dsn status, but that won't be quite good for the server, considering the flow of emails coming in. I need a way to get the status of the mail and store it in a DB or file.

Thanks, Alin


Once the PHP mail function concludes without an error code the message has been accepted by the MTA (postfix, sendmail or whatever is your favourite) the interaction between your script and the MTA has ended.

Once the SMTP message is in the mail queue it will be tried for immediate delivery and may actually be delivered immediately, or delivery could fail immediately, but the message can also sit in the queue (for minutes, hours or even days) due to transient problems before final delivery or failure.

In case of a (long temporary) failure the normal behaviour of a MTA would be to send a delivery notification to the sender. No failure notification would signify succesful remote delivery (where the message may still be (silently) discarded).

You can monitor the mailbox of that sender and for instance filter delivery notifications to a PHP script that will categorise them and upload them to your database.

  • Thanks for the heads up, now i know how the system fully works. I guess i have to come up with another ideea, since i usually have a lot of emails in queue and need to filter them. My main problem is the status, the library that im using right now it only give 0 ok on every mail even when it has issues. Thank you for your time. – Alin Andrei Dec 2 '13 at 14:26
  • 1
    The typical mailing would of course include tracking code and/or tracking images in the messages itself to determine they were read and such and rely on the notifications to remove invalid email addresses and such. – HBruijn Dec 2 '13 at 15:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.