Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...

When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Sending via SMTP

To send mail via SMTP, Zend_Mail_Transport_Smtp needs to be created and registered with Zend_Mail before the send() method is called. For all remaining Zend_Mail::send() calls in the current script, the SMTP transport will then be used:

Example 592. Sending E-Mail via SMTP

= new Zend_Mail_Transport_Smtp('');

The setDefaultTransport() method and the constructor of Zend_Mail_Transport_Smtp are not expensive. These two lines can be processed at script setup time (e.g., or similar) to configure the behavior of the Zend_Mail class for the rest of the script. This keeps configuration information out of the application logic - whether mail is sent via SMTP or mail(), what mail server is used, etc.

Zend Framework