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

Configuring the default sendmail transport

The default transport for a Zend_Mail instance is Zend_Mail_Transport_Sendmail. It is essentially a wrapper to the PHP mail() function. If you wish to pass additional parameters to the mail() function, simply create a new transport instance and pass your parameters to the constructor. The new transport instance can then act as the default Zend_Mail transport, or it can be passed to the send() method of Zend_Mail.

Example 591.  Passing additional parameters to the Zend_Mail_Transport_Sendmail transport

This example shows how to change the Return-Path of the mail() function.

= new Zend_Mail_Transport_Sendmail('');

$mail = new Zend_Mail();
$mail->setBodyText('This is the text of the mail.');
$mail->setFrom('''Some Sender');
$mail->addTo('''Some Recipient');

Safe mode restrictions

The optional additional parameters will be cause the mail() function to fail if PHP is running in safe mode.

Sendmail Transport and Windows

As the PHP manual states the mail() function has different behaviour on Windows and on *nix based systems. Using the Sendmail Transport on Windows will not work in combination with addBcc(). The mail() function will sent to the BCC recipient such that all the other recipients can see him as recipient!

Therefore if you want to use BCC on a windows server, use the SMTP transport for sending!

Zend Framework