API Documentation

Mail.php

Includes Classes 
category
Zend
copyright
Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
license
http://framework.zend.com/license/new-bsd New BSD License
package
Zend_Mail
version
$Id: Mail.php 20783 2010-01-31 08:06:30Z yoshida@zend.co.jp $
Classes
Zend_Mail

Description

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.

Zend_Mail

Extends from
Zend_Mime_Message
category
Zend
copyright
Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
license
http://framework.zend.com/license/new-bsd New BSD License
package
Zend_Mail
Properties
$_defaultTransport
$_defaultFrom
$_defaultReplyTo
$_charset
$_headers
$_headerEncoding
$_from
$_to
$_recipients
$_replyTo
$_returnPath
$_subject
$_date
$_messageId
$_bodyText
$_bodyHtml
$_mimeBoundary
$_type
$hasAttachments
Methods
setDefaultTransport
getDefaultTransport
clearDefaultTransport
__construct
getCharset
setType
getType
setMimeBoundary
getMimeBoundary
getEncodingOfHeaders
getHeaderEncoding
setEncodingOfHeaders
setHeaderEncoding
setBodyText
getBodyText
setBodyHtml
getBodyHtml
addAttachment
createAttachment
getPartCount
_encodeHeader
_storeHeader
_clearHeader
_addRecipientAndHeader
addTo
addCc
addBcc
getRecipients
clearRecipients
setFrom
setReplyTo
getFrom
getReplyTo
clearFrom
clearReplyTo
setDefaultFrom
getDefaultFrom
clearDefaultFrom
setFromToDefaultFrom
setDefaultReplyTo
getDefaultReplyTo
clearDefaultReplyTo
setReplyToFromDefault
setReturnPath
getReturnPath
clearReturnPath
setSubject
getSubject
clearSubject
setDate
getDate
clearDate
setMessageId
getMessageId
clearMessageId
createMessageId
addHeader
getHeaders
send
_filterEmail
_filterName
_filterOther
_formatAddress

Description

Class for sending an email.

Properties

$_bodyHtml

false|Zend_Mime_Part $_bodyHtml = 'false'

text/html MIME part

Details

$_bodyHtml
false|Zend_Mime_Part
visibility
protected
default
false
final
false
static
false

$_bodyText

false|Zend_Mime_Part $_bodyText = 'false'

text/plain MIME part

Details

$_bodyText
false|Zend_Mime_Part
visibility
protected
default
false
final
false
static
false

$_charset

string $_charset = 'null'

Mail character set

Details

$_charset
string
visibility
protected
default
null
final
false
static
false

$_date

string $_date = 'null'

Date: header

Details

$_date
string
visibility
protected
default
null
final
false
static
false

$_defaultFrom

array $_defaultFrom = ''

Details

$_defaultFrom
array
visibility
protected
default
final
false
static
true
static

$_defaultReplyTo

array $_defaultReplyTo = ''

Details

$_defaultReplyTo
array
visibility
protected
default
final
false
static
true
static

$_defaultTransport

Zend_Mail_Transport_Abstract $_defaultTransport = 'null'

Details

$_defaultTransport
Zend_Mail_Transport_Abstract
visibility
protected
default
null
final
false
static
true
static

$_from

string $_from = 'null'

From: address

Details

$_from
string
visibility
protected
default
null
final
false
static
false

$_headerEncoding

string $_headerEncoding = 'Zend_Mime'

Encoding of Mail headers

Details

$_headerEncoding
string
visibility
protected
default
Zend_Mime
final
false
static
false

$_headers

array $_headers = 'array'

Mail headers

Details

$_headers
array
visibility
protected
default
array
final
false
static
false

$_messageId

string $_messageId = 'null'

Message-ID: header

Details

$_messageId
string
visibility
protected
default
null
final
false
static
false

$_mimeBoundary

string $_mimeBoundary = 'null'

MIME boundary string

Details

$_mimeBoundary
string
visibility
protected
default
null
final
false
static
false

$_recipients

array $_recipients = 'array'

Array of all recipients

Details

$_recipients
array
visibility
protected
default
array
final
false
static
false

$_replyTo

string $_replyTo = 'null'

Reply-To header

Details

$_replyTo
string
visibility
protected
default
null
final
false
static
false

$_returnPath

string $_returnPath = 'null'

Return-Path header

Details

$_returnPath
string
visibility
protected
default
null
final
false
static
false

$_subject

string $_subject = 'null'

Subject: header

Details

$_subject
string
visibility
protected
default
null
final
false
static
false

$_to

array $_to = 'array'

To: addresses

Details

$_to
array
visibility
protected
default
array
final
false
static
false

$_type

string $_type = 'null'

Content type of the message

Details

$_type
string
visibility
protected
default
null
final
false
static
false

$hasAttachments

boolean $hasAttachments = 'false'

Flag: whether or not email has attachments

Details

$hasAttachments
boolean
visibility
public
default
false
final
false
static
false

Methods

__construct

__construct( string $charset = iso-8859-1 ) :

Public constructor

Arguments
$charset
string
Details
visibility
public
final
false
static
false

_addRecipientAndHeader

_addRecipientAndHeader( string $headerName, string $email, string $name ) :

Helper function for adding a recipient and the corresponding header

Arguments
$headerName
string
$email
string
$name
string
Details
visibility
protected
final
false
static
false

_clearHeader

_clearHeader( string $headerName ) :

Clear header from the message

Arguments
$headerName
string
Details
visibility
protected
final
false
static
false

_encodeHeader

_encodeHeader( string $value ) : string

Encode header fields

Encodes header content according to RFC1522 if it contains non-printable characters.

Arguments
$value
string
Output
string
Details
visibility
protected
final
false
static
false

_filterEmail

_filterEmail( string $email ) : string

Filter of email data

Arguments
$email
string
Output
string
Details
visibility
protected
final
false
static
false

_filterName

_filterName( string $name ) : string

Filter of name data

Arguments
$name
string
Output
string
Details
visibility
protected
final
false
static
false

_filterOther

_filterOther( string $data ) : string

Filter of other data

Arguments
$data
string
Output
string
Details
visibility
protected
final
false
static
false

_formatAddress

_formatAddress( string $email, string $name ) : string

Formats e-mail address

Arguments
$email
string
$name
string
Output
string
Details
visibility
protected
final
false
static
false

_storeHeader

_storeHeader( string $headerName, string $value, bool $append = false ) :

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.

Arguments
$headerName
string
$value
string
$append
bool
Details
visibility
protected
final
false
static
false

addAttachment

addAttachment( Zend_Mime_Part $attachment ) : Zend_Mail

Adds an existing attachment to the mail message

Arguments
$attachment
Zend_Mime_Part
Output
Zend_Mail
Provides fluent interface
Details
visibility
public
final
false
static
false

addBcc

addBcc( string|array $email ) : Zend_Mail

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

Arguments
$email
stringarray
Output
Zend_Mail
Provides fluent interface
Details
visibility
public
final
false
static
false

addCc

addCc( string|array $email, string $name ) : Zend_Mail

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

Arguments
$email
stringarray
$name
string
Output
Zend_Mail
Provides fluent interface
Details
visibility
public
final
false
static
false

addHeader

addHeader( string $name, string $value, boolean $append = false ) : Zend_Mail

Add a custom header to the message

Arguments
$name
string
$value
string
$append
boolean
Output
Zend_Mail
Provides fluent interface
Details
visibility
public
final
false
static
false
throws
on attempts to create standard headers

addTo

addTo( string|array $email, string $name ) : Zend_Mail

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

Arguments
$email
stringarray
$name
string
Output
Zend_Mail
Provides fluent interface
Details
visibility
public
final
false
static
false

clearDate

clearDate( ) : Zend_Mail

Clears the formatted date from the message

Output
Zend_Mail
Provides fluent interface
Details
visibility
public
final
false
static
false

clearDefaultFrom

clearDefaultFrom( ) : void

Clears the default sender from the mail

Details
visibility
public
final
false
static
true

clearDefaultReplyTo

clearDefaultReplyTo( ) : void

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

Details
visibility
public
final
false
static
true

clearDefaultTransport

clearDefaultTransport( ) :

Clear the default transport property

Details
visibility
public
final
false
static
true

clearFrom

clearFrom( ) : Zend_Mail

Clears the sender from the mail

Output
Zend_Mail
Provides fluent interface
Details
visibility
public
final
false
static
false

clearMessageId

clearMessageId( ) : Zend_Mail

Clears the Message-ID from the message

Output
Zend_Mail
Provides fluent interface
Details
visibility
public
final
false
static
false

clearRecipients

clearRecipients( ) : Zend_Mail

Clears list of recipient email addresses

Output
Zend_Mail
Provides fluent interface
Details
visibility
public
final
false
static
false

clearReplyTo

clearReplyTo( ) : Zend_Mail

Clears the current Reply-To address from the message

Output
Zend_Mail
Provides fluent interface
Details
visibility
public
final
false
static
false

clearReturnPath

clearReturnPath( ) : Zend_Mail

Clears the current Return-Path address from the message

Output
Zend_Mail
Provides fluent interface
Details
visibility
public
final
false
static
false

clearSubject

clearSubject( ) : Zend_Mail

Clears the encoded subject from the message

Output
Zend_Mail
Provides fluent interface
Details
visibility
public
final
false
static
false

createAttachment

createAttachment( string $body, string $mimeType = Zend_Mime, string $disposition = Zend_Mime, string $encoding = Zend_Mime, 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.

Arguments
$body
string
$mimeType
string
$disposition
string
$encoding
string
$filename
string
OPTIONAL A filename for the attachment
Output
Zend_Mime_Part
Newly created Zend_Mime_Part object (to allow advanced settings)
Details
visibility
public
final
false
static
false

createMessageId

createMessageId( ) : string

Creates the Message-ID

Output
string
Details
visibility
public
final
false
static
false

getBodyHtml

getBodyHtml( bool $htmlOnly = false ) : false|Zend_Mime_Part|string

Return Zend_Mime_Part representing body HTML

Arguments
$htmlOnly
bool
Whether to return the body HTML only, or the MIME part; defaults to false, the MIME part
Output
false|Zend_Mime_Part|string
Details
visibility
public
final
false
static
false

getBodyText

getBodyText( bool $textOnly = false ) : false|Zend_Mime_Part|string

Return text body Zend_Mime_Part or string

Arguments
$textOnly
bool
textOnly Whether to return just the body text content or the MIME part; defaults to false, the MIME part
Output
false|Zend_Mime_Part|string
Details
visibility
public
final
false
static
false

getCharset

getCharset( ) : string

Return charset string

Output
string
Details
visibility
public
final
false
static
false

getDate

getDate( ) : string

Returns the formatted date of the message

Output
string
Details
visibility
public
final
false
static
false

getDefaultFrom

getDefaultFrom( ) : null|array

Returns the default sender of the mail

Output
null|array
Null if none was set.
Details
visibility
public
final
false
static
true

getDefaultReplyTo

getDefaultReplyTo( ) : null|array

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

Output
null|array
Null if none was set.
Details
visibility
public
final
false
static
true

getDefaultTransport

getDefaultTransport( ) :

Gets the default mail transport for all following uses of unittests

Details
visibility
public
final
false
static
true
todo
Allow passing a string to indicate the transport to load
todo
Allow passing in optional options for the transport to load

getEncodingOfHeaders

getEncodingOfHeaders( ) : string

Return encoding of mail headers

Output
string
Details
visibility
public
final
false
static
false
deprecated
use {@link getHeaderEncoding()} instead

getFrom

getFrom( ) : string

Returns the sender of the mail

Output
string
Details
visibility
public
final
false
static
false

getHeaderEncoding

getHeaderEncoding( ) : string

Return the encoding of mail headers

Either Zend_Mime::ENCODING_QUOTEDPRINTABLE or Zend_Mime::ENCODING_BASE64

Output
string
Details
visibility
public
final
false
static
false

getHeaders

getHeaders( ) : void

Return mail headers

Details
visibility
public
final
false
static
false

getMessageId

getMessageId( ) : string

Returns the Message-ID of the message

Output
string
Details
visibility
public
final
false
static
false

getMimeBoundary

getMimeBoundary( ) : string

Return the boundary string used for the message

Output
string
Details
visibility
public
final
false
static
false

getPartCount

getPartCount( ) : integer

Return a count of message parts

Output
integer
Details
visibility
public
final
false
static
false

getRecipients

getRecipients( ) : array

Return list of recipient email addresses

Output
array
(of strings)
Details
visibility
public
final
false
static
false

getReplyTo

getReplyTo( ) : string|null

Returns the current Reply-To address of the message

Output
string|null
Reply-To address, null when not set
Details
visibility
public
final
false
static
false

getReturnPath

getReturnPath( ) : string

Returns the current Return-Path address of the message

If no Return-Path header is set, returns the value of {@link $_from}.

Output
string
Details
visibility
public
final
false
static
false

getSubject

getSubject( ) : string

Returns the encoded subject of the message

Output
string
Details
visibility
public
final
false
static
false

getType

getType( ) : string

Get content type of the message

Output
string
Details
visibility
public
final
false
static
false

send

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.

Arguments
$transport
Zend_Mail_Transport_Abstract
Output
Zend_Mail
Provides fluent interface
Details
visibility
public
final
false
static
false

setBodyHtml

setBodyHtml( string $html, string $charset = null, string $encoding = Zend_Mime ) : Zend_Mail

Sets the HTML body for the message

Arguments
$html
string
$charset
string
$encoding
string
Output
Zend_Mail
Provides fluent interface
Details
visibility
public
final
false
static
false

setBodyText

setBodyText( string $txt, string $charset = null, string $encoding = Zend_Mime ) : Zend_Mail

Sets the text body for the message.

Arguments
$txt
string
$charset
string
$encoding
string
Output
Zend_Mail
Provides fluent interface
Details
visibility
public
final
false
static
false

setDate

setDate( timestamp|string|Zend_Date $date = null ) : Zend_Mail

Sets Date-header

Arguments
$date
timestampstringZend_Date
Output
Zend_Mail
Provides fluent interface
Details
visibility
public
final
false
static
false
throws
if called subsequent times or wrong date format.

setDefaultFrom

setDefaultFrom( string $email, string $name = null ) : void

Sets Default From-email and name of the message

Arguments
$email
string
$name
string
Optional $name
Details
visibility
public
final
false
static
true

setDefaultReplyTo

setDefaultReplyTo( string $email, string $name = null ) : void

Sets Default ReplyTo-address and -name of the message

Arguments
$email
string
$name
string
Optional $name
Details
visibility
public
final
false
static
true

setDefaultTransport

setDefaultTransport( Zend_Mail_Transport_Abstract $transport ) :

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

Arguments
$transport
Zend_Mail_Transport_Abstract
Details
visibility
public
final
false
static
true
todo
Allow passing a string to indicate the transport to load
todo
Allow passing in optional options for the transport to load

setEncodingOfHeaders

setEncodingOfHeaders( string $encoding ) : Zend_Mail

Set the encoding of mail headers

Arguments
$encoding
string
Output
Zend_Mail
Details
visibility
public
final
false
static
false
deprecated
Use {@link setHeaderEncoding()} instead.

setFrom

setFrom( string $email, string $name = null ) : Zend_Mail

Sets From-header and sender of the message

Arguments
$email
string
$name
string
Output
Zend_Mail
Provides fluent interface
Details
visibility
public
final
false
static
false
throws
if called subsequent times

setFromToDefaultFrom

setFromToDefaultFrom( ) : Zend_Mail

Sets From-name and -email based on the defaults

Output
Zend_Mail
Provides fluent interface
Details
visibility
public
final
false
static
false

setHeaderEncoding

setHeaderEncoding( string $encoding ) : Zend_Mail

Set the encoding of mail headers

Arguments
$encoding
string
Zend_Mime::ENCODING_QUOTEDPRINTABLE or Zend_Mime::ENCODING_BASE64
Output
Zend_Mail
Provides fluent interface
Details
visibility
public
final
false
static
false

setMessageId

setMessageId( boolean|string $id = true ) : Zend_Mail

Sets the Message-ID of the message

Arguments
$id
booleanstring
true :Auto false :No set null :No set string:Sets given string (Angle brackets is not necessary)
Output
Zend_Mail
Provides fluent interface
Details
visibility
public
final
false
static
false
throws

setMimeBoundary

setMimeBoundary( string $boundary ) : Zend_Mail

Set an arbitrary mime boundary for the message

If not set, Zend_Mime will generate one.

Arguments
$boundary
string
Output
Zend_Mail
Provides fluent interface
Details
visibility
public
final
false
static
false

setReplyTo

setReplyTo( string $email, string $name = null ) : Zend_Mail

Set Reply-To Header

Arguments
$email
string
$name
string
Output
Zend_Mail
Details
visibility
public
final
false
static
false
throws
if called more than one time

setReplyToFromDefault

setReplyToFromDefault( ) : Zend_Mail

Sets ReplyTo-name and -email based on the defaults

Output
Zend_Mail
Provides fluent interface
Details
visibility
public
final
false
static
false

setReturnPath

setReturnPath( string $email ) : Zend_Mail

Sets the Return-Path header of the message

Arguments
$email
string
Output
Zend_Mail
Provides fluent interface
Details
visibility
public
final
false
static
false
throws
if set multiple times

setSubject

setSubject( string $subject ) : Zend_Mail

Sets the subject of the message

Arguments
$subject
string
Output
Zend_Mail
Provides fluent interface
Details
visibility
public
final
false
static
false
throws

setType

setType( string $type ) : Zend_Mail

Set content type

Should only be used for manually setting multipart content types.

Arguments
$type
string
Content type
Output
Zend_Mail
Implements fluent interface
Details
visibility
public
final
false
static
false
throws
for types not supported by Zend_Mime
Documentation was generated by DocBlox.