IntroductionGetting startedZend_Mail provides generalized functionality to compose and send both text and MIME-compliant multipart e-mail messages. Mail can be sent with Zend_Mail via the default Zend_Mail_Transport_Sendmail transport or via Zend_Mail_Transport_Smtp. Example #1 Simple E-Mail with Zend_Mail A simple e-mail consists of some recipients, a subject, a body and a sender. To send such a mail using Zend_Mail_Transport_Sendmail, do the following:
For most mail attributes there are "get" methods to read the information stored in the mail object. For further details, please refer to the API documentation. A special one is getRecipients(). It returns an array with all recipient e-mail addresses that were added prior to the method call.
For security reasons, Zend_Mail filters all header fields to prevent header injection with
newline ( You also can use most methods of the Zend_Mail object with a convenient fluent interface.
Configuring the default sendmail transportThe 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 #2 Passing additional parameters to the Zend_Mail_Transport_Sendmail transport This example shows how to change the Return-Path of the » mail() function.
|
|