Mail.php
Zend Framework
LICENSE
This source file is subject to the new BSD license that is bundled
with this package in the file LICENSE.txt.
It is also available through the world-wide-web at this URL:
http://framework.zend.com/license/new-bsd
If you did not receive a copy of the license and are unable to
obtain it through the world-wide-web, please send an email
to license@zend.com so we can send you a copy immediately.
- Category
- Zend
- Copyright
- Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_Mail
- Version
- $Id$
Package: Zend_MailClass for sending an email.
- Parent(s)
- \Zend_Mime_Message
- Category
- Zend
- Copyright
- Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
Properties



string $_type = nullContent type of the message
Default valuenullDetails- Type
- string



boolean $hasAttachments = falseFlag: whether or not email has attachments
Default valuefalseDetails- Type
- boolean
Methods



_addRecipientAndHeader(string $headerName, string $email, string $name) : voidHelper function for adding a recipient and the corresponding header
Parameters| Name | Type | Description |
|---|
| $headerName | string | |
|---|
| $email | string | |
|---|
| $name | string | |
|---|



_clearHeader(string $headerName) : voidClear header from the message
Parameters| Name | Type | Description |
|---|
| $headerName | string | |
|---|
Details- Deprecated
- use public method directly



_storeHeader(string $headerName, string $value, bool $append = false) : voidAdd a header to the message
Adds a header to this message. If append is true and the header already
exists, raises a flag indicating that the header should be appended.
Parameters| Name | Type | Description |
|---|
| $headerName | string | |
|---|
| $value | string | |
|---|
| $append | bool | |
|---|



addBcc(string | array $email) : \Zend_MailAdds Bcc recipient, $email can be an array, or a single string address
Parameters| Name | Type | Description |
|---|
| $email | string | array | |
|---|
Returns| Type | Description |
|---|
| \Zend_Mail | Provides fluent interface |



addCc(string | array $email, string $name = '') : \Zend_MailAdds Cc-header and recipient, $email can be an array, or a single string address
Parameters| Name | Type | Description |
|---|
| $email | string | array | |
|---|
| $name | string | |
|---|
Returns| Type | Description |
|---|
| \Zend_Mail | Provides fluent interface |



addHeader(string $name, string $value, boolean $append = false) : \Zend_MailAdd a custom header to the message
Parameters| Name | Type | Description |
|---|
| $name | string | |
|---|
| $value | string | |
|---|
| $append | boolean | |
|---|
Returns| Type | Description |
|---|
| \Zend_Mail | Provides fluent interface |
Throws 


addTo(string | array $email, string $name = '') : \Zend_MailAdds To-header and recipient, $email can be an array, or a single string address
Parameters| Name | Type | Description |
|---|
| $email | string | array | |
|---|
| $name | string | |
|---|
Returns| Type | Description |
|---|
| \Zend_Mail | Provides fluent interface |



clearDate() : \Zend_MailClears the formatted date from the message
Returns| Type | Description |
|---|
| \Zend_Mail | Provides fluent interface |



clearFrom() : \Zend_MailClears the sender from the mail
Returns| Type | Description |
|---|
| \Zend_Mail | Provides fluent interface |



clearHeader(string $headerName) : \Zend_MailClear header from the message
Parameters| Name | Type | Description |
|---|
| $headerName | string | |
|---|
Returns 


clearMessageId() : \Zend_MailClears the Message-ID from the message
Returns| Type | Description |
|---|
| \Zend_Mail | Provides fluent interface |



clearRecipients() : \Zend_MailClears list of recipient email addresses
Returns| Type | Description |
|---|
| \Zend_Mail | Provides fluent interface |



clearReplyTo() : \Zend_MailClears the current Reply-To address from the message
Returns| Type | Description |
|---|
| \Zend_Mail | Provides fluent interface |



clearReturnPath() : \Zend_MailClears the current Return-Path address from the message
Returns| Type | Description |
|---|
| \Zend_Mail | Provides fluent interface |



clearSubject() : \Zend_MailClears the encoded subject from the message
Returns| Type | Description |
|---|
| \Zend_Mail | Provides fluent interface |



createAttachment(string $body, string $mimeType = \Zend_Mime::TYPE_OCTETSTREAM, string $disposition = \Zend_Mime::DISPOSITION_ATTACHMENT, string $encoding = \Zend_Mime::ENCODING_BASE64, string $filename = null) : \Zend_Mime_PartCreates a Zend_Mime_Part attachment
Attachment is automatically added to the mail object after creation. The
attachment object is returned to allow for further manipulation.
Parameters| Name | Type | Description |
|---|
| $body | string | |
|---|
| $mimeType | string | |
|---|
| $disposition | string | |
|---|
| $encoding | string | |
|---|
| $filename | string | OPTIONAL A filename for the attachment |
|---|
Returns| Type | Description |
|---|
| \Zend_Mime_Part | Newly created Zend_Mime_Part object (to allow
advanced settings) |



getBodyHtml(bool $htmlOnly = false) : false | \Zend_Mime_Part | stringReturn Zend_Mime_Part representing body HTML
Parameters| Name | Type | Description |
|---|
| $htmlOnly | bool | Whether to return the body HTML only, or the MIME part; defaults to false, the MIME part |
|---|
Returns 


getBodyText( $textOnly = false) : false | \Zend_Mime_Part | stringReturn text body Zend_Mime_Part or string
Parameters| Name | Type | Description |
|---|
| $textOnly | | |
|---|
Returns 


getDefaultFrom() : null | arraystaticReturns the default sender of the mail
Returns| Type | Description |
|---|
| null | array | Null if none was set. |



getDefaultReplyTo() : null | arraystaticReturns the default Reply-To Address and Name of the mail
Returns| Type | Description |
|---|
| null | array | Null if none was set. |



getDefaultTransport() : voidstaticGets the default mail transport for all following uses of
unittests
Details- Todo
- Allow passing a string to indicate the transport to load
- Todo
- Allow passing in optional options for the transport to load



getEncodingOfHeaders() : stringReturn encoding of mail headers
ReturnsDetails- Deprecated
- use {@link getHeaderEncoding()} instead



getHeaderEncoding() : stringReturn the encoding of mail headers
Either Zend_Mime::ENCODING_QUOTEDPRINTABLE or Zend_Mime::ENCODING_BASE64
Returns


getRecipients() : arrayReturn list of recipient email addresses
Returns| Type | Description |
|---|
| array | (of strings) |



getReplyTo() : string | nullReturns the current Reply-To address of the message
Returns| Type | Description |
|---|
| string | null | Reply-To address, null when not set |



getReturnPath() : stringReturns the current Return-Path address of the message
If no Return-Path header is set, returns the value of {@link $_from}.
Returns


send(\Zend_Mail_Transport_Abstract $transport = null) : \Zend_MailSends this email using the given transport or a previously
set DefaultTransport or the internal mail function if no
default transport had been set.
ParametersReturns| Type | Description |
|---|
| \Zend_Mail | Provides fluent interface |



setBodyHtml(string $html, string $charset = null, string $encoding = \Zend_Mime::ENCODING_QUOTEDPRINTABLE) : \Zend_MailSets the HTML body for the message
Parameters| Name | Type | Description |
|---|
| $html | string | |
|---|
| $charset | string | |
|---|
| $encoding | string | |
|---|
Returns| Type | Description |
|---|
| \Zend_Mail | Provides fluent interface |



setBodyText(string $txt, string $charset = null, string $encoding = \Zend_Mime::ENCODING_QUOTEDPRINTABLE) : \Zend_MailSets the text body for the message.
Parameters| Name | Type | Description |
|---|
| $txt | string | |
|---|
| $charset | string | |
|---|
| $encoding | string | |
|---|
Returns| Type | Description |
|---|
| \Zend_Mail | Provides fluent interface |



setDefaultFrom(string $email, $name = null) : voidstaticSets Default From-email and name of the message
Parameters| Name | Type | Description |
|---|
| $email | string | |
|---|
| $name | | |
|---|



setDefaultReplyTo(string $email, $name = null) : voidstaticSets Default ReplyTo-address and -name of the message
Parameters| Name | Type | Description |
|---|
| $email | string | |
|---|
| $name | | |
|---|



setDefaultTransport(\Zend_Mail_Transport_Abstract $transport) : voidstaticSets the default mail transport for all following uses of
Zend_Mail::send();
ParametersDetails- Todo
- Allow passing a string to indicate the transport to load
- Todo
- Allow passing in optional options for the transport to load



setEncodingOfHeaders(string $encoding) : \Zend_MailSet the encoding of mail headers
Parameters| Name | Type | Description |
|---|
| $encoding | string | |
|---|
ReturnsDetails- Deprecated
- Use {@link setHeaderEncoding()} instead.



setFrom(string $email, string $name = null) : \Zend_MailSets From-header and sender of the message
Parameters| Name | Type | Description |
|---|
| $email | string | |
|---|
| $name | string | |
|---|
Returns| Type | Description |
|---|
| \Zend_Mail | Provides fluent interface |
Throws 


setFromToDefaultFrom() : \Zend_MailSets From-name and -email based on the defaults
Returns| Type | Description |
|---|
| \Zend_Mail | Provides fluent interface |



setHeaderEncoding(string $encoding) : \Zend_MailSet the encoding of mail headers
Parameters| Name | Type | Description |
|---|
| $encoding | string | Zend_Mime::ENCODING_QUOTEDPRINTABLE or Zend_Mime::ENCODING_BASE64 |
|---|
Returns| Type | Description |
|---|
| \Zend_Mail | Provides fluent interface |



setMessageId(boolean | string $id = true) : \Zend_MailSets the Message-ID of the message
Parameters| Name | Type | Description |
|---|
| $id | boolean | string | true :Auto
false :No set
null :No set
string:Sets given string (Angle brackets is not necessary) |
|---|
Returns| Type | Description |
|---|
| \Zend_Mail | Provides fluent interface |
Throws 


setMimeBoundary(string $boundary) : \Zend_MailSet an arbitrary mime boundary for the message
If not set, Zend_Mime will generate one.
Parameters| Name | Type | Description |
|---|
| $boundary | string | |
|---|
Returns| Type | Description |
|---|
| \Zend_Mail | Provides fluent interface |



setReplyToFromDefault() : \Zend_MailSets ReplyTo-name and -email based on the defaults
Returns| Type | Description |
|---|
| \Zend_Mail | Provides fluent interface |



setReturnPath(string $email) : \Zend_MailSets the Return-Path header of the message
Parameters| Name | Type | Description |
|---|
| $email | string | |
|---|
Returns| Type | Description |
|---|
| \Zend_Mail | Provides fluent interface |
Throws 


setSubject(string $subject) : \Zend_MailSets the subject of the message
Parameters| Name | Type | Description |
|---|
| $subject | string | |
|---|
Returns| Type | Description |
|---|
| \Zend_Mail | Provides fluent interface |
Throws 


setType(string $type) : \Zend_MailShould only be used for manually setting multipart content types.
Parameters| Name | Type | Description |
|---|
| $type | string | Content type |
|---|
Returns| Type | Description |
|---|
| \Zend_Mail | Implements fluent interface |
Throws