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 [email protected] so we can send you a copy immediately.
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
-
New BSD License
- Package
- Zend_Mail
- Version
- $Id: Mail.php 24593 2012-01-05 20:35:02Z matthew $
Package: Zend\MailClass for sending an email.
- Parent(s)
- \Zend_Mime_Message
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
-
New BSD License
Properties



string $_type = null
Content type of the message
Default valuenull
Details
- Type
- string



boolean $hasAttachments = false
Flag: whether or not email has attachments
Default valuefalse
Details
- Type
- boolean
Methods



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



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



_storeHeader(string $headerName, string $value, bool $append = false) : void
Add 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 |
|



addAttachment(\Zend_Mime_Part $attachment) : \Zend_Mail
Adds an existing attachment to the mail message
Parameters
Returns
Type |
Description |
\Zend_Mail |
Provides fluent interface |



addBcc(string | array $email) : \Zend_Mail
Adds 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_Mail
Adds 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_Mail
Add 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_Mail
Adds 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_Mail
Clears the formatted date from the message
Returns
Type |
Description |
\Zend_Mail |
Provides fluent interface |



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



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



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



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



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



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



clearSubject() : \Zend_Mail
Clears 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_Part
Creates 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) |



createFromMessage(string $message, string $boundary, string $EOL = \Zend_Mime::LINEEND) : \Zend_Mime_Message
staticinheritedDecodes a MIME encoded string and returns a Zend_Mime_Message object with
all the MIME parts set according to the given string
Inherited from:
\Zend_Mime_Message::createFromMessage()
Parameters
Name |
Type |
Description |
$message |
string |
|
$boundary |
string |
|
$EOL |
string |
EOL string; defaults to {@link Zend_Mime::LINEEND}
|
Returns



generateMessage(string $EOL = \Zend_Mime::LINEEND) : string
This can be a multipart message if more than one MIME part was added. If
only one part is present, the content of this part is returned. If no
part had been added, an empty string is returned.
Parts are seperated by the mime boundary as defined in Zend_Mime. If
setMime() has been called before this method, the Zend_Mime
object set by this call will be used. Otherwise, a new Zend_Mime object
is generated and used.
Parameters
Name |
Type |
Description |
$EOL |
string |
EOL string; defaults to {@link Zend_Mime::LINEEND}
|
Returns



getBodyHtml(bool $htmlOnly = false) : false | \Zend_Mime_Part | string
Return 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(bool $textOnly = false) : false | \Zend_Mime_Part | string
Return text body Zend_Mime_Part or string
Parameters
Name |
Type |
Description |
$textOnly |
bool |
textOnly Whether to return just the body text content or the MIME part; defaults to false, the MIME part |
Returns



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



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



getDefaultTransport() : void
staticGets 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() : string
Return encoding of mail headers
Returns
Details
- Deprecated
- use {@link getHeaderEncoding()} instead



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



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



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



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



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



setBodyHtml(string $html, string $charset = null, string $encoding = \Zend_Mime::ENCODING_QUOTEDPRINTABLE) : \Zend_Mail
Sets 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_Mail
Sets 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, string $name = null) : void
staticSets Default From-email and name of the message
Parameters
Name |
Type |
Description |
$email |
string |
|
$name |
string |
Optional $name
|



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



setDefaultTransport(\Zend_Mail_Transport_Abstract $transport) : void
staticSets the default mail transport for all following uses of
Zend_Mail::send();
Parameters
Details
- 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_Mail
Set the encoding of mail headers
Parameters
Name |
Type |
Description |
$encoding |
string |
|
Returns
Details
- Deprecated
- Use {@link setHeaderEncoding()} instead.



setFrom(string $email, string $name = null) : \Zend_Mail
Sets 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_Mail
Sets From-name and -email based on the defaults
Returns
Type |
Description |
\Zend_Mail |
Provides fluent interface |



setHeaderEncoding(string $encoding) : \Zend_Mail
Set 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_Mail
Sets 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_Mail
Set 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_Mail
Sets ReplyTo-name and -email based on the defaults
Returns
Type |
Description |
\Zend_Mail |
Provides fluent interface |



setReturnPath(string $email) : \Zend_Mail
Sets 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_Mail
Sets the subject of the message
Parameters
Name |
Type |
Description |
$subject |
string |
|
Returns
Type |
Description |
\Zend_Mail |
Provides fluent interface |
Throws



setType(string $type) : \Zend_Mail
Should 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