Mail.php

Show: PublicProtectedPrivateinherited
Table of Contents
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-2014 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Package
Zend_Mail  
Version
$Id$  

\Zend_Mail

Package: Zend_Mail
Class 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

>VPropertyprotectedfalse|\Zend_Mime_Part $_bodyHtml = false
text/html MIME part
Default valuefalseDetails
Type
false | \Zend_Mime_Part
>VPropertyprotectedfalse|\Zend_Mime_Part $_bodyText = false
text/plain MIME part
Default valuefalseDetails
Type
false | \Zend_Mime_Part
>VPropertyprotectedstring $_charset = 'iso-8859-1'
Mail character set
Default value'iso-8859-1'Details
Type
string
>VPropertyprotectedstring $_date = null
Date: header
Default valuenullDetails
Type
string
>VPropertyprotectedarray $_defaultFrom
static
Details
Type
array
Static
 
>VPropertyprotectedarray $_defaultReplyTo
static
Details
Type
array
Static
 
>VPropertyprotected\Zend_Mail_Transport_Abstract $_defaultTransport = null
static
Default valuenullDetails
Type
\Zend_Mail_Transport_Abstract
Static
 
>VPropertyprotectedstring $_from = null
From: address
Default valuenullDetails
Type
string
>VPropertyprotectedstring $_headerEncoding = \Zend_Mime::ENCODING_QUOTEDPRINTABLE
Encoding of Mail headers
Default value\Zend_Mime::ENCODING_QUOTEDPRINTABLEDetails
Type
string
>VPropertyprotectedarray $_headers = array()
Mail headers
Default valuearray()Details
Type
array
>VPropertyprotectedstring $_messageId = null
Message-ID: header
Default valuenullDetails
Type
string
>VPropertyprotectedstring $_mimeBoundary = null
MIME boundary string
Default valuenullDetails
Type
string
>VPropertyprotectedarray $_recipients = array()
Array of all recipients
Default valuearray()Details
Type
array
>VPropertyprotectedstring $_replyTo = null
Reply-To header
Default valuenullDetails
Type
string
>VPropertyprotectedstring $_returnPath = null
Return-Path header
Default valuenullDetails
Type
string
>VPropertyprotectedstring $_subject = null
Subject: header
Default valuenullDetails
Type
string
>VPropertyprotectedarray $_to = array()
To: addresses
Default valuearray()Details
Type
array
>VPropertyprotectedstring $_type = null
Content type of the message
Default valuenullDetails
Type
string
>VPropertypublicboolean $hasAttachments = false
Flag: whether or not email has attachments
Default valuefalseDetails
Type
boolean

Methods

methodpublic__construct(string $charset = null) : void

Public constructor

Parameters
NameTypeDescription
$charsetstring
methodprotected_addRecipientAndHeader(string $headerName, string $email, string $name) : void

Helper function for adding a recipient and the corresponding header

Parameters
NameTypeDescription
$headerNamestring
$emailstring
$namestring
methodprotected_clearHeader(string $headerName) : void

Clear header from the message

Parameters
NameTypeDescription
$headerNamestring
Details
Deprecated
use public method directly  
methodprotected_encodeHeader(string $value) : string

Encode header fields

Encodes header content according to RFC1522 if it contains non-printable characters.
Parameters
NameTypeDescription
$valuestring
Returns
TypeDescription
string
methodprotected_filterEmail(string $email) : string

Filter of email data

Parameters
NameTypeDescription
$emailstring
Returns
TypeDescription
string
methodprotected_filterName(string $name) : string

Filter of name data

Parameters
NameTypeDescription
$namestring
Returns
TypeDescription
string
methodprotected_filterOther(string $data) : string

Filter of other data

Parameters
NameTypeDescription
$datastring
Returns
TypeDescription
string
methodprotected_formatAddress(string $email, string $name) : string

Formats e-mail address

Parameters
NameTypeDescription
$emailstring
$namestring
Returns
TypeDescription
string
methodprotected_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
NameTypeDescription
$headerNamestring
$valuestring
$appendbool
methodpublicaddAttachment(\Zend_Mime_Part $attachment) : \Zend_Mail

Adds an existing attachment to the mail message

Parameters
NameTypeDescription
$attachment\Zend_Mime_Part
Returns
TypeDescription
\Zend_MailProvides fluent interface
methodpublicaddBcc(string | array $email) : \Zend_Mail

Adds Bcc recipient, $email can be an array, or a single string address

Parameters
NameTypeDescription
$emailstring | array
Returns
TypeDescription
\Zend_MailProvides fluent interface
methodpublicaddCc(string | array $email, string $name = '') : \Zend_Mail

Adds Cc-header and recipient, $email can be an array, or a single string address

Parameters
NameTypeDescription
$emailstring | array
$namestring
Returns
TypeDescription
\Zend_MailProvides fluent interface
methodpublicaddHeader(string $name, string $value, boolean $append = false) : \Zend_Mail

Add a custom header to the message

Parameters
NameTypeDescription
$namestring
$valuestring
$appendboolean
Returns
TypeDescription
\Zend_MailProvides fluent interface
Throws
ExceptionDescription
\Zend_Mail_Exceptionon attempts to create standard headers
methodpublicaddTo(string | array $email, string $name = '') : \Zend_Mail

Adds To-header and recipient, $email can be an array, or a single string address

Parameters
NameTypeDescription
$emailstring | array
$namestring
Returns
TypeDescription
\Zend_MailProvides fluent interface
methodpublicclearDate() : \Zend_Mail

Clears the formatted date from the message

Returns
TypeDescription
\Zend_MailProvides fluent interface
methodpublicclearDefaultFrom() : void
static

Clears the default sender from the mail

methodpublicclearDefaultReplyTo() : void
static

Clears the default ReplyTo-address and -name from the mail

methodpublicclearDefaultTransport() : void
static

Clear the default transport property

methodpublicclearFrom() : \Zend_Mail

Clears the sender from the mail

Returns
TypeDescription
\Zend_MailProvides fluent interface
methodpublicclearHeader(string $headerName) : \Zend_Mail

Clear header from the message

Parameters
NameTypeDescription
$headerNamestring
Returns
TypeDescription
\Zend_MailProvides fluent inter
methodpublicclearMessageId() : \Zend_Mail

Clears the Message-ID from the message

Returns
TypeDescription
\Zend_MailProvides fluent interface
methodpublicclearRecipients() : \Zend_Mail

Clears list of recipient email addresses

Returns
TypeDescription
\Zend_MailProvides fluent interface
methodpublicclearReplyTo() : \Zend_Mail

Clears the current Reply-To address from the message

Returns
TypeDescription
\Zend_MailProvides fluent interface
methodpublicclearReturnPath() : \Zend_Mail

Clears the current Return-Path address from the message

Returns
TypeDescription
\Zend_MailProvides fluent interface
methodpublicclearSubject() : \Zend_Mail

Clears the encoded subject from the message

Returns
TypeDescription
\Zend_MailProvides fluent interface
methodpubliccreateAttachment(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
NameTypeDescription
$bodystring
$mimeTypestring
$dispositionstring
$encodingstring
$filenamestring

OPTIONAL A filename for the attachment

Returns
TypeDescription
\Zend_Mime_PartNewly created Zend_Mime_Part object (to allow advanced settings)
methodpubliccreateMessageId() : string

Creates the Message-ID

Returns
TypeDescription
string
methodpublicgetBodyHtml(bool $htmlOnly = false) : false | \Zend_Mime_Part | string

Return Zend_Mime_Part representing body HTML

Parameters
NameTypeDescription
$htmlOnlybool

Whether to return the body HTML only, or the MIME part; defaults to false, the MIME part

Returns
TypeDescription
false | \Zend_Mime_Part | string
methodpublicgetBodyText( $textOnly = false) : false | \Zend_Mime_Part | string

Return text body Zend_Mime_Part or string

Parameters
NameTypeDescription
$textOnly
Returns
TypeDescription
false | \Zend_Mime_Part | string
methodpublicgetCharset() : string

Return charset string

Returns
TypeDescription
string
methodpublicgetDate() : string

Returns the formatted date of the message

Returns
TypeDescription
string
methodpublicgetDefaultFrom() : null | array
static

Returns the default sender of the mail

Returns
TypeDescription
null | arrayNull if none was set.
methodpublicgetDefaultReplyTo() : null | array
static

Returns the default Reply-To Address and Name of the mail

Returns
TypeDescription
null | arrayNull if none was set.
methodpublicgetDefaultTransport() : void
static

Gets 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  
methodpublicgetEncodingOfHeaders() : string

Return encoding of mail headers

Returns
TypeDescription
string
Details
Deprecated
use {@link getHeaderEncoding()} instead  
methodpublicgetFrom() : string

Returns the sender of the mail

Returns
TypeDescription
string
methodpublicgetHeaderEncoding() : string

Return the encoding of mail headers

Either Zend_Mime::ENCODING_QUOTEDPRINTABLE or Zend_Mime::ENCODING_BASE64
Returns
TypeDescription
string
methodpublicgetHeaders() : void

Return mail headers

methodpublicgetMessageId() : string

Returns the Message-ID of the message

Returns
TypeDescription
string
methodpublicgetMimeBoundary() : string

Return the boundary string used for the message

Returns
TypeDescription
string
methodpublicgetPartCount() : integer

Return a count of message parts

Returns
TypeDescription
integer
methodpublicgetRecipients() : array

Return list of recipient email addresses

Returns
TypeDescription
array(of strings)
methodpublicgetReplyTo() : string | null

Returns the current Reply-To address of the message

Returns
TypeDescription
string | nullReply-To address, null when not set
methodpublicgetReturnPath() : string

Returns the current Return-Path address of the message

If no Return-Path header is set, returns the value of {@link $_from}.
Returns
TypeDescription
string
methodpublicgetSubject() : string

Returns the encoded subject of the message

Returns
TypeDescription
string
methodpublicgetType() : string

Get content type of the message

Returns
TypeDescription
string
methodpublicsend(\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
NameTypeDescription
$transport\Zend_Mail_Transport_Abstract
Returns
TypeDescription
\Zend_MailProvides fluent interface
methodpublicsetBodyHtml(string $html, string $charset = null, string $encoding = \Zend_Mime::ENCODING_QUOTEDPRINTABLE) : \Zend_Mail

Sets the HTML body for the message

Parameters
NameTypeDescription
$htmlstring
$charsetstring
$encodingstring
Returns
TypeDescription
\Zend_MailProvides fluent interface
methodpublicsetBodyText(string $txt, string $charset = null, string $encoding = \Zend_Mime::ENCODING_QUOTEDPRINTABLE) : \Zend_Mail

Sets the text body for the message.

Parameters
NameTypeDescription
$txtstring
$charsetstring
$encodingstring
Returns
TypeDescription
\Zend_MailProvides fluent interface
methodpublicsetDate(\timestamp | string | \Zend_Date $date = null) : \Zend_Mail

Sets Date-header

Parameters
NameTypeDescription
$date\timestamp | string | \Zend_Date
Returns
TypeDescription
\Zend_MailProvides fluent interface
Throws
ExceptionDescription
\Zend_Mail_Exceptionif called subsequent times or wrong date format.
methodpublicsetDefaultFrom(string $email,  $name = null) : void
static

Sets Default From-email and name of the message

Parameters
NameTypeDescription
$emailstring
$name
methodpublicsetDefaultReplyTo(string $email,  $name = null) : void
static

Sets Default ReplyTo-address and -name of the message

Parameters
NameTypeDescription
$emailstring
$name
methodpublicsetDefaultTransport(\Zend_Mail_Transport_Abstract $transport) : void
static

Sets the default mail transport for all following uses of Zend_Mail::send();

Parameters
NameTypeDescription
$transport\Zend_Mail_Transport_Abstract
Details
Todo
Allow passing a string to indicate the transport to load  
Todo
Allow passing in optional options for the transport to load  
methodpublicsetEncodingOfHeaders(string $encoding) : \Zend_Mail

Set the encoding of mail headers

Parameters
NameTypeDescription
$encodingstring
Returns
TypeDescription
\Zend_Mail
Details
Deprecated
Use {@link setHeaderEncoding()} instead.  
methodpublicsetFrom(string $email, string $name = null) : \Zend_Mail

Sets From-header and sender of the message

Parameters
NameTypeDescription
$emailstring
$namestring
Returns
TypeDescription
\Zend_MailProvides fluent interface
Throws
ExceptionDescription
\Zend_Mail_Exceptionif called subsequent times
methodpublicsetFromToDefaultFrom() : \Zend_Mail

Sets From-name and -email based on the defaults

Returns
TypeDescription
\Zend_MailProvides fluent interface
methodpublicsetHeaderEncoding(string $encoding) : \Zend_Mail

Set the encoding of mail headers

Parameters
NameTypeDescription
$encodingstring

Zend_Mime::ENCODING_QUOTEDPRINTABLE or Zend_Mime::ENCODING_BASE64

Returns
TypeDescription
\Zend_MailProvides fluent interface
methodpublicsetMessageId(boolean | string $id = true) : \Zend_Mail

Sets the Message-ID of the message

Parameters
NameTypeDescription
$idboolean | string

true :Auto false :No set null :No set string:Sets given string (Angle brackets is not necessary)

Returns
TypeDescription
\Zend_MailProvides fluent interface
Throws
ExceptionDescription
\Zend_Mail_Exception
methodpublicsetMimeBoundary(string $boundary) : \Zend_Mail

Set an arbitrary mime boundary for the message

If not set, Zend_Mime will generate one.
Parameters
NameTypeDescription
$boundarystring
Returns
TypeDescription
\Zend_MailProvides fluent interface
methodpublicsetReplyTo(string $email, string $name = null) : \Zend_Mail

Set Reply-To Header

Parameters
NameTypeDescription
$emailstring
$namestring
Returns
TypeDescription
\Zend_Mail
Throws
ExceptionDescription
\Zend_Mail_Exceptionif called more than one time
methodpublicsetReplyToFromDefault() : \Zend_Mail

Sets ReplyTo-name and -email based on the defaults

Returns
TypeDescription
\Zend_MailProvides fluent interface
methodpublicsetReturnPath(string $email) : \Zend_Mail

Sets the Return-Path header of the message

Parameters
NameTypeDescription
$emailstring
Returns
TypeDescription
\Zend_MailProvides fluent interface
Throws
ExceptionDescription
\Zend_Mail_Exceptionif set multiple times
methodpublicsetSubject(string $subject) : \Zend_Mail

Sets the subject of the message

Parameters
NameTypeDescription
$subjectstring
Returns
TypeDescription
\Zend_MailProvides fluent interface
Throws
ExceptionDescription
\Zend_Mail_Exception
methodpublicsetType(string $type) : \Zend_Mail

Set content type

Should only be used for manually setting multipart content types.
Parameters
NameTypeDescription
$typestring

Content type

Returns
TypeDescription
\Zend_MailImplements fluent interface
Throws
ExceptionDescription
\Zend_Mail_Exceptionfor types not supported by Zend_Mime
Documentation was generated by phpDocumentor 2.2.0 .