How to verify a mail has been sent when using Zend_Mail? How to verify a mail has been sent when using Zend_Mail? php php

How to verify a mail has been sent when using Zend_Mail?


Generally Zend_Mail will throw an exception if there is something wrong going on on the send-process - but this strongly depends on the Zend_Mail_Transport_* being used.

You have two options here:

  • Zend_Mail_Transport_Sendmail (the default transport) relies on mail(). If mail() returns false, Zend_Mail_Transport_Sendmail throws a Zend_Mail_Transport_Exception (Unable to send mail). The return value itself is not very reliable. This is what the manual says about the return value:

    Returns TRUE if the mail was successfully accepted for delivery, FALSE otherwise.

    It is important to note that just because the mail was accepted for delivery, it does NOT mean the mail will actually reach the intended destination.

  • Zend_Mail_Transport_Smtp sends the email using the SMTP protocol that's encapsulated in Zend_Mail_Protocol_Smtp. In this case you'll get a Zend_Mail_Protocol_Exception whenever something either violates the SMTP protocol (sending mail without giving a sender's address e.g.) or the STMP server reports an error or the connection times out.

    So if no exception is thrown when talking to the STMP server, you can be sure that the remote server at least accepted your email.


I guess it's not. If "sending" failed you get an exception. But that's only a check, that the send() function worked properly. It doesn't mean the mail got send.

I guess the only way to ensude the mail was delivered is to insert a confirmation code link inte the mail and make user click it.