PHP Class Zend_Mail

Inheritance: extends Zend_Mime_Message
Show file Open project: kimai/kimai Class Usage Examples

Public Properties

Property Type Description
$hasAttachments boolean Flag: whether or not email has attachments

Protected Properties

Property Type Description
$_bodyHtml false | Zend_Mime_Part text/html MIME part
$_bodyText false | Zend_Mime_Part text/plain MIME part
$_charset string Mail character set
$_date string Date: header
$_defaultFrom array
$_defaultReplyTo array
$_defaultTransport Zend_Mail_Transport_Abstract
$_from string From: address
$_headerEncoding string Encoding of Mail headers
$_headers array Mail headers
$_messageId string Message-ID: header
$_mimeBoundary string MIME boundary string
$_recipients array Array of all recipients
$_replyTo string Reply-To header
$_returnPath string Return-Path header
$_subject string Subject: header
$_to array To: addresses
$_type string Content type of the message

Public Methods

Method Description
__construct ( string $charset = null ) Public constructor
addAttachment ( Zend_Mime_Part $attachment ) : Zend_Mail Adds an existing attachment to the mail message
addBcc ( string | array $email ) : Zend_Mail Adds Bcc recipient, $email can be an array, or a single string address
addCc ( string | array $email, string $name = '' ) : Zend_Mail Adds Cc-header and recipient, $email can be an array, or a single string address
addHeader ( string $name, string $value, boolean $append = false ) : Zend_Mail Add a custom header to the message
addTo ( string | array $email, string $name = '' ) : Zend_Mail Adds To-header and recipient, $email can be an array, or a single string address
clearDate ( ) : Zend_Mail Clears the formatted date from the message
clearDefaultFrom ( ) : void Clears the default sender from the mail
clearDefaultReplyTo ( ) : void Clears the default ReplyTo-address and -name from the mail
clearDefaultTransport ( ) Clear the default transport property
clearFrom ( ) : Zend_Mail Clears the sender from the mail
clearHeader ( string $headerName ) : Zend_Mail Clear header from the message
clearMessageId ( ) : Zend_Mail Clears the Message-ID from the message
clearRecipients ( ) : Zend_Mail Clears list of recipient email addresses
clearReplyTo ( ) : Zend_Mail Clears the current Reply-To address from the message
clearReturnPath ( ) : Zend_Mail Clears the current Return-Path address from the message
clearSubject ( ) : Zend_Mail Clears the encoded subject from the message
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
createMessageId ( ) : string Creates the Message-ID
getBodyHtml ( boolean $htmlOnly = false ) : false | Zend_Mime_Part | string Return Zend_Mime_Part representing body HTML
getBodyText ( boolean $textOnly = false ) : false | Zend_Mime_Part | string Return text body Zend_Mime_Part or string
getCharset ( ) : string Return charset string
getDate ( ) : string Returns the formatted date of the message
getDefaultFrom ( ) : null | array Returns the default sender of the mail
getDefaultReplyTo ( ) : null | array Returns the default Reply-To Address and Name of the mail
getDefaultTransport ( ) Gets the default mail transport for all following uses of unittests
getEncodingOfHeaders ( ) : string Return encoding of mail headers
getFrom ( ) : string Returns the sender of the mail
getHeaderEncoding ( ) : string Return the encoding of mail headers
getHeaders ( ) : array Return mail headers
getMessageId ( ) : string Returns the Message-ID of the message
getMimeBoundary ( ) : string Return the boundary string used for the message
getPartCount ( ) : integer Return a count of message parts
getRecipients ( ) : array Return list of recipient email addresses
getReplyTo ( ) : string | null Returns the current Reply-To address of the message
getReturnPath ( ) : string Returns the current Return-Path address of the message
getSubject ( ) : string Returns the encoded subject of the message
getType ( ) : string Get content type of the message
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.
setBodyHtml ( string $html, string $charset = null, string $encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE ) : Zend_Mail Sets the HTML body for the message
setBodyText ( string $txt, string $charset = null, string $encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE ) : Zend_Mail Sets the text body for the message.
setDate ( integer | string | Zend_Date $date = null ) : Zend_Mail Sets Date-header
setDefaultFrom ( string $email, string $name = null ) : void Sets Default From-email and name of the message
setDefaultReplyTo ( string $email, string $name = null ) : void Sets Default ReplyTo-address and -name of the message
setDefaultTransport ( Zend_Mail_Transport_Abstract $transport ) Sets the default mail transport for all following uses of Zend_Mail::send();
setEncodingOfHeaders ( string $encoding ) : Zend_Mail Set the encoding of mail headers
setFrom ( string $email, string $name = null ) : Zend_Mail Sets From-header and sender of the message
setFromToDefaultFrom ( ) : Zend_Mail Sets From-name and -email based on the defaults
setHeaderEncoding ( string $encoding ) : Zend_Mail Set the encoding of mail headers
setMessageId ( boolean | string $id = true ) : Zend_Mail Sets the Message-ID of the message
setMimeBoundary ( string $boundary ) : Zend_Mail Set an arbitrary mime boundary for the message
setReplyTo ( string $email, string $name = null ) : Zend_Mail Set Reply-To Header
setReplyToFromDefault ( ) : Zend_Mail Sets ReplyTo-name and -email based on the defaults
setReturnPath ( string $email ) : Zend_Mail Sets the Return-Path header of the message
setSubject ( string $subject ) : Zend_Mail Sets the subject of the message
setType ( string $type ) : Zend_Mail Set content type

Protected Methods

Method Description
_addRecipientAndHeader ( string $headerName, string $email, string $name ) Helper function for adding a recipient and the corresponding header
_clearHeader ( string $headerName ) Clear header from the message
_encodeHeader ( string $value ) : string Encode header fields
_filterEmail ( string $email ) : string Filter of email data
_filterName ( string $name ) : string Filter of name data
_filterOther ( string $data ) : string Filter of other data
_formatAddress ( string $email, string $name ) : string Formats e-mail address
_storeHeader ( string $headerName, string $value, boolean $append = false ) Add a header to the message

Method Details

__construct() public method

Public constructor
public __construct ( string $charset = null )
$charset string

_addRecipientAndHeader() protected method

Helper function for adding a recipient and the corresponding header
protected _addRecipientAndHeader ( string $headerName, string $email, string $name )
$headerName string
$email string
$name string

_clearHeader() protected method

Clear header from the message
Deprecation: use public method directly
protected _clearHeader ( string $headerName )
$headerName string

_encodeHeader() protected method

Encodes header content according to RFC1522 if it contains non-printable characters.
protected _encodeHeader ( string $value ) : string
$value string
return string

_filterEmail() protected method

Filter of email data
protected _filterEmail ( string $email ) : string
$email string
return string

_filterName() protected method

Filter of name data
protected _filterName ( string $name ) : string
$name string
return string

_filterOther() protected method

Filter of other data
protected _filterOther ( string $data ) : string
$data string
return string

_formatAddress() protected method

Formats e-mail address
protected _formatAddress ( string $email, string $name ) : string
$email string
$name string
return string

_storeHeader() protected method

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.
protected _storeHeader ( string $headerName, string $value, boolean $append = false )
$headerName string
$value string
$append boolean

addAttachment() public method

Adds an existing attachment to the mail message
public addAttachment ( Zend_Mime_Part $attachment ) : Zend_Mail
$attachment Zend_Mime_Part
return Zend_Mail Provides fluent interface

addBcc() public method

Adds Bcc recipient, $email can be an array, or a single string address
public addBcc ( string | array $email ) : Zend_Mail
$email string | array
return Zend_Mail Provides fluent interface

addCc() public method

Adds Cc-header and recipient, $email can be an array, or a single string address
public addCc ( string | array $email, string $name = '' ) : Zend_Mail
$email string | array
$name string
return Zend_Mail Provides fluent interface

addHeader() public method

Add a custom header to the message
public addHeader ( string $name, string $value, boolean $append = false ) : Zend_Mail
$name string
$value string
$append boolean
return Zend_Mail Provides fluent interface

addTo() public method

Adds To-header and recipient, $email can be an array, or a single string address
public addTo ( string | array $email, string $name = '' ) : Zend_Mail
$email string | array
$name string
return Zend_Mail Provides fluent interface

clearDate() public method

Clears the formatted date from the message
public clearDate ( ) : Zend_Mail
return Zend_Mail Provides fluent interface

clearDefaultFrom() public static method

Clears the default sender from the mail
public static clearDefaultFrom ( ) : void
return void

clearDefaultReplyTo() public static method

Clears the default ReplyTo-address and -name from the mail
public static clearDefaultReplyTo ( ) : void
return void

clearDefaultTransport() public static method

Clear the default transport property
public static clearDefaultTransport ( )

clearFrom() public method

Clears the sender from the mail
public clearFrom ( ) : Zend_Mail
return Zend_Mail Provides fluent interface

clearHeader() public method

Clear header from the message
public clearHeader ( string $headerName ) : Zend_Mail
$headerName string
return Zend_Mail Provides fluent inter

clearMessageId() public method

Clears the Message-ID from the message
public clearMessageId ( ) : Zend_Mail
return Zend_Mail Provides fluent interface

clearRecipients() public method

Clears list of recipient email addresses
public clearRecipients ( ) : Zend_Mail
return Zend_Mail Provides fluent interface

clearReplyTo() public method

Clears the current Reply-To address from the message
public clearReplyTo ( ) : Zend_Mail
return Zend_Mail Provides fluent interface

clearReturnPath() public method

Clears the current Return-Path address from the message
public clearReturnPath ( ) : Zend_Mail
return Zend_Mail Provides fluent interface

clearSubject() public method

Clears the encoded subject from the message
public clearSubject ( ) : Zend_Mail
return Zend_Mail Provides fluent interface

createAttachment() public method

Attachment is automatically added to the mail object after creation. The attachment object is returned to allow for further manipulation.
public 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
$body string
$mimeType string
$disposition string
$encoding string
$filename string OPTIONAL A filename for the attachment
return Zend_Mime_Part Newly created Zend_Mime_Part object (to allow advanced settings)

createMessageId() public method

Creates the Message-ID
public createMessageId ( ) : string
return string

getBodyHtml() public method

Return Zend_Mime_Part representing body HTML
public getBodyHtml ( boolean $htmlOnly = false ) : false | Zend_Mime_Part | string
$htmlOnly boolean Whether to return the body HTML only, or the MIME part; defaults to false, the MIME part
return false | Zend_Mime_Part | string

getBodyText() public method

Return text body Zend_Mime_Part or string
public getBodyText ( boolean $textOnly = false ) : false | Zend_Mime_Part | string
$textOnly boolean Whether to return just the body text content or the MIME part; defaults to false, the MIME part
return false | Zend_Mime_Part | string

getCharset() public method

Return charset string
public getCharset ( ) : string
return string

getDate() public method

Returns the formatted date of the message
public getDate ( ) : string
return string

getDefaultFrom() public static method

Returns the default sender of the mail
public static getDefaultFrom ( ) : null | array
return null | array Null if none was set.

getDefaultReplyTo() public static method

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

getDefaultTransport() public static method

Gets the default mail transport for all following uses of unittests
public static getDefaultTransport ( )

getEncodingOfHeaders() public method

Return encoding of mail headers
Deprecation: use {@link getHeaderEncoding()} instead
public getEncodingOfHeaders ( ) : string
return string

getFrom() public method

Returns the sender of the mail
public getFrom ( ) : string
return string

getHeaderEncoding() public method

Either Zend_Mime::ENCODING_QUOTEDPRINTABLE or Zend_Mime::ENCODING_BASE64
public getHeaderEncoding ( ) : string
return string

getHeaders() public method

Return mail headers
public getHeaders ( ) : array
return array

getMessageId() public method

Returns the Message-ID of the message
public getMessageId ( ) : string
return string

getMimeBoundary() public method

Return the boundary string used for the message
public getMimeBoundary ( ) : string
return string

getPartCount() public method

Return a count of message parts
public getPartCount ( ) : integer
return integer

getRecipients() public method

Return list of recipient email addresses
public getRecipients ( ) : array
return array (of strings)

getReplyTo() public method

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

getReturnPath() public method

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

getSubject() public method

Returns the encoded subject of the message
public getSubject ( ) : string
return string

getType() public method

Get content type of the message
public getType ( ) : string
return string

send() public method

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

setBodyHtml() public method

Sets the HTML body for the message
public setBodyHtml ( string $html, string $charset = null, string $encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE ) : Zend_Mail
$html string
$charset string
$encoding string
return Zend_Mail Provides fluent interface

setBodyText() public method

Sets the text body for the message.
public setBodyText ( string $txt, string $charset = null, string $encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE ) : Zend_Mail
$txt string
$charset string
$encoding string
return Zend_Mail Provides fluent interface

setDate() public method

Sets Date-header
public setDate ( integer | string | Zend_Date $date = null ) : Zend_Mail
$date integer | string | Zend_Date
return Zend_Mail Provides fluent interface

setDefaultFrom() public static method

Sets Default From-email and name of the message
public static setDefaultFrom ( string $email, string $name = null ) : void
$email string
$name string optional
return void

setDefaultReplyTo() public static method

Sets Default ReplyTo-address and -name of the message
public static setDefaultReplyTo ( string $email, string $name = null ) : void
$email string
$name string optional
return void

setDefaultTransport() public static method

Sets the default mail transport for all following uses of Zend_Mail::send();
public static setDefaultTransport ( Zend_Mail_Transport_Abstract $transport )
$transport Zend_Mail_Transport_Abstract

setEncodingOfHeaders() public method

Set the encoding of mail headers
Deprecation: Use {@link setHeaderEncoding()} instead.
public setEncodingOfHeaders ( string $encoding ) : Zend_Mail
$encoding string
return Zend_Mail

setFrom() public method

Sets From-header and sender of the message
public setFrom ( string $email, string $name = null ) : Zend_Mail
$email string
$name string
return Zend_Mail Provides fluent interface

setFromToDefaultFrom() public method

Sets From-name and -email based on the defaults
public setFromToDefaultFrom ( ) : Zend_Mail
return Zend_Mail Provides fluent interface

setHeaderEncoding() public method

Set the encoding of mail headers
public setHeaderEncoding ( string $encoding ) : Zend_Mail
$encoding string Zend_Mime::ENCODING_QUOTEDPRINTABLE or Zend_Mime::ENCODING_BASE64
return Zend_Mail Provides fluent interface

setMessageId() public method

Sets the Message-ID of the message
public setMessageId ( boolean | string $id = true ) : Zend_Mail
$id boolean | string true :Auto false :No set null :No set string:Sets given string (Angle brackets is not necessary)
return Zend_Mail Provides fluent interface

setMimeBoundary() public method

If not set, Zend_Mime will generate one.
public setMimeBoundary ( string $boundary ) : Zend_Mail
$boundary string
return Zend_Mail Provides fluent interface

setReplyTo() public method

Set Reply-To Header
public setReplyTo ( string $email, string $name = null ) : Zend_Mail
$email string
$name string
return Zend_Mail

setReplyToFromDefault() public method

Sets ReplyTo-name and -email based on the defaults
public setReplyToFromDefault ( ) : Zend_Mail
return Zend_Mail Provides fluent interface

setReturnPath() public method

Sets the Return-Path header of the message
public setReturnPath ( string $email ) : Zend_Mail
$email string
return Zend_Mail Provides fluent interface

setSubject() public method

Sets the subject of the message
public setSubject ( string $subject ) : Zend_Mail
$subject string
return Zend_Mail Provides fluent interface

setType() public method

Should only be used for manually setting multipart content types.
public setType ( string $type ) : Zend_Mail
$type string Content type
return Zend_Mail Implements fluent interface

Property Details

$_bodyHtml protected property

text/html MIME part
protected false|Zend_Mime_Part $_bodyHtml
return false | Zend_Mime_Part

$_bodyText protected property

text/plain MIME part
protected false|Zend_Mime_Part $_bodyText
return false | Zend_Mime_Part

$_charset protected property

Mail character set
protected string $_charset
return string

$_date protected property

Date: header
protected string $_date
return string

$_defaultFrom protected static property

protected static array $_defaultFrom
return array

$_defaultReplyTo protected static property

protected static array $_defaultReplyTo
return array

$_defaultTransport protected static property

protected static Zend_Mail_Transport_Abstract $_defaultTransport
return Zend_Mail_Transport_Abstract

$_from protected property

From: address
protected string $_from
return string

$_headerEncoding protected property

Encoding of Mail headers
protected string $_headerEncoding
return string

$_headers protected property

Mail headers
protected array $_headers
return array

$_messageId protected property

Message-ID: header
protected string $_messageId
return string

$_mimeBoundary protected property

MIME boundary string
protected string $_mimeBoundary
return string

$_recipients protected property

Array of all recipients
protected array $_recipients
return array

$_replyTo protected property

Reply-To header
protected string $_replyTo
return string

$_returnPath protected property

Return-Path header
protected string $_returnPath
return string

$_subject protected property

Subject: header
protected string $_subject
return string

$_to protected property

To: addresses
protected array $_to
return array

$_type protected property

Content type of the message
protected string $_type
return string

$hasAttachments public property

Flag: whether or not email has attachments
public bool $hasAttachments
return boolean