Zend Framework  1.12
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
Zend_Mail Class Reference

Public Member Functions

 __construct ($charset=null)
 Public constructor.
 
 getCharset ()
 Return charset string.
 
 setType ($type)
 Set content type.
 
 getType ()
 Get content type of the message.
 
 setMimeBoundary ($boundary)
 Set an arbitrary mime boundary for the message.
 
 getMimeBoundary ()
 Return the boundary string used for the message.
 
 getEncodingOfHeaders ()
 Return encoding of mail headers.
 
 getHeaderEncoding ()
 Return the encoding of mail headers.
 
 setEncodingOfHeaders ($encoding)
 Set the encoding of mail headers.
 
 setHeaderEncoding ($encoding)
 Set the encoding of mail headers.
 
 setBodyText ($txt, $charset=null, $encoding=Zend_Mime::ENCODING_QUOTEDPRINTABLE)
 Sets the text body for the message.
 
 getBodyText ($textOnly=false)
 Return text body Zend_Mime_Part or string.
 
 setBodyHtml ($html, $charset=null, $encoding=Zend_Mime::ENCODING_QUOTEDPRINTABLE)
 Sets the HTML body for the message.
 
 getBodyHtml ($htmlOnly=false)
 Return Zend_Mime_Part representing body HTML.
 
 addAttachment (Zend_Mime_Part $attachment)
 Adds an existing attachment to the mail message.
 
 createAttachment ($body, $mimeType=Zend_Mime::TYPE_OCTETSTREAM, $disposition=Zend_Mime::DISPOSITION_ATTACHMENT, $encoding=Zend_Mime::ENCODING_BASE64, $filename=null)
 Creates a Zend_Mime_Part attachment.
 
 getPartCount ()
 Return a count of message parts.
 
 addTo ($email, $name='')
 Adds To-header and recipient, $email can be an array, or a single string address.
 
 addCc ($email, $name='')
 Adds Cc-header and recipient, $email can be an array, or a single string address.
 
 addBcc ($email)
 Adds Bcc recipient, $email can be an array, or a single string address.
 
 getRecipients ()
 Return list of recipient email addresses.
 
 clearHeader ($headerName)
 Clear header from the message.
 
 clearRecipients ()
 Clears list of recipient email addresses.
 
 setFrom ($email, $name=null)
 Sets From-header and sender of the message.
 
 setReplyTo ($email, $name=null)
 Set Reply-To Header.
 
 getFrom ()
 Returns the sender of the mail.
 
 getReplyTo ()
 Returns the current Reply-To address of the message.
 
 clearFrom ()
 Clears the sender from the mail.
 
 clearReplyTo ()
 Clears the current Reply-To address from the message.
 
 setFromToDefaultFrom ()
 Sets From-name and -email based on the defaults.
 
 setReplyToFromDefault ()
 Sets ReplyTo-name and -email based on the defaults.
 
 setReturnPath ($email)
 Sets the Return-Path header of the message.
 
 getReturnPath ()
 Returns the current Return-Path address of the message.
 
 clearReturnPath ()
 Clears the current Return-Path address from the message.
 
 setSubject ($subject)
 Sets the subject of the message.
 
 getSubject ()
 Returns the encoded subject of the message.
 
 clearSubject ()
 Clears the encoded subject from the message.
 
 setDate ($date=null)
 Sets Date-header.
 
 getDate ()
 Returns the formatted date of the message.
 
 clearDate ()
 Clears the formatted date from the message.
 
 setMessageId ($id=true)
 Sets the Message-ID of the message.
 
 getMessageId ()
 Returns the Message-ID of the message.
 
 clearMessageId ()
 Clears the Message-ID from the message.
 
 createMessageId ()
 Creates the Message-ID.
 
 addHeader ($name, $value, $append=false)
 Add a custom header to the message.
 
 getHeaders ()
 Return mail headers.
 
 send ($transport=null)
 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 Member Functions inherited from Zend_Mime_Message
 getParts ()
 Returns the list of all Zend_Mime_Parts in the message.
 
 setParts ($parts)
 Sets the given array of Zend_Mime_Parts as the array for the message.
 
 addPart (Zend_Mime_Part $part)
 Append a new Zend_Mime_Part to the current message.
 
 isMultiPart ()
 Check if message needs to be sent as multipart MIME message or if it has only one part.
 
 setMime (Zend_Mime $mime)
 Set Zend_Mime object for the message.
 
 getMime ()
 Returns the Zend_Mime object in use by the message.
 
 generateMessage ($EOL=Zend_Mime::LINEEND)
 Generate MIME-compliant message from the current configuration.
 
 getPartHeadersArray ($partnum)
 Get the headers of a given part as an array.
 
 getPartHeaders ($partnum, $EOL=Zend_Mime::LINEEND)
 Get the headers of a given part as a string.
 
 getPartContent ($partnum, $EOL=Zend_Mime::LINEEND)
 Get the (encoded) content of a given part as a string.
 

Static Public Member Functions

static setDefaultTransport (Zend_Mail_Transport_Abstract $transport)
 Sets the default mail transport for all following uses of Zend_Mail::send();.
 
static getDefaultTransport ()
 Gets the default mail transport for all following uses of unittests.
 
static clearDefaultTransport ()
 Clear the default transport property.
 
static setDefaultFrom ($email, $name=null)
 Sets Default From-email and name of the message.
 
static getDefaultFrom ()
 Returns the default sender of the mail.
 
static clearDefaultFrom ()
 Clears the default sender from the mail.
 
static setDefaultReplyTo ($email, $name=null)
 Sets Default ReplyTo-address and -name of the message.
 
static getDefaultReplyTo ()
 Returns the default Reply-To Address and Name of the mail.
 
static clearDefaultReplyTo ()
 Clears the default ReplyTo-address and -name from the mail.
 
- Static Public Member Functions inherited from Zend_Mime_Message
static createFromMessage ($message, $boundary, $EOL=Zend_Mime::LINEEND)
 Decodes a MIME encoded string and returns a Zend_Mime_Message object with all the MIME parts set according to the given string.
 

Public Attributes

 $hasAttachments = false
 

Protected Member Functions

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

Protected Attributes

 $_charset = 'iso-8859-1'
 
 $_headers = array()
 
 $_headerEncoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE
 
 $_from = null
 
 $_to = array()
 
 $_recipients = array()
 
 $_replyTo = null
 
 $_returnPath = null
 
 $_subject = null
 
 $_date = null
 
 $_messageId = null
 
 $_bodyText = false
 
 $_bodyHtml = false
 
 $_mimeBoundary = null
 
 $_type = null
 
- Protected Attributes inherited from Zend_Mime_Message
 $_parts = array()
 
 $_mime = null
 

Static Protected Attributes

static $_defaultTransport = null
 
static $_defaultFrom
 
static $_defaultReplyTo
 

Additional Inherited Members

- Static Protected Member Functions inherited from Zend_Mime_Message
static _disassembleMime ($body, $boundary)
 Explode MIME multipart string into seperate parts.
 

Constructor & Destructor Documentation

__construct (   $charset = null)

Public constructor.

Parameters
string$charset
Returns
void

Member Function Documentation

_addRecipientAndHeader (   $headerName,
  $email,
  $name 
)
protected

Helper function for adding a recipient and the corresponding header.

Parameters
string$headerName
string$email
string$name
_clearHeader (   $headerName)
protected

Clear header from the message.

Parameters
string$headerName
Deprecated:
use public method directly
_encodeHeader (   $value)
protected

Encode header fields.

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

Parameters
string$value
Returns
string
_filterEmail (   $email)
protected

Filter of email data.

Parameters
string$email
Returns
string
_filterName (   $name)
protected

Filter of name data.

Parameters
string$name
Returns
string
_filterOther (   $data)
protected

Filter of other data.

Parameters
string$data
Returns
string
_formatAddress (   $email,
  $name 
)
protected

Formats e-mail address.

Parameters
string$email
string$name
Returns
string
_storeHeader (   $headerName,
  $value,
  $append = false 
)
protected

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
string$headerName
string$value
bool$append
addAttachment ( Zend_Mime_Part  $attachment)

Adds an existing attachment to the mail message.

Parameters
Zend_Mime_Part$attachment
Returns
Zend_Mail Provides fluent interface
addBcc (   $email)

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

Parameters
string | array$email
Returns
Zend_Mail Provides fluent interface
addCc (   $email,
  $name = '' 
)

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

Parameters
string | array$email
string$name
Returns
Zend_Mail Provides fluent interface
addHeader (   $name,
  $value,
  $append = false 
)

Add a custom header to the message.

Parameters
string$name
string$value
boolean$append
Returns
Zend_Mail Provides fluent interface
Exceptions
Zend_Mail_Exceptionon attempts to create standard headers
See Also
Zend_Mail_Exception
addTo (   $email,
  $name = '' 
)

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

Parameters
string | array$email
string$name
Returns
Zend_Mail Provides fluent interface
clearDate ( )

Clears the formatted date from the message.

Returns
Zend_Mail Provides fluent interface
static clearDefaultFrom ( )
static

Clears the default sender from the mail.

Returns
void
static clearDefaultReplyTo ( )
static

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

Returns
void
static clearDefaultTransport ( )
static

Clear the default transport property.

clearFrom ( )

Clears the sender from the mail.

Returns
Zend_Mail Provides fluent interface
clearHeader (   $headerName)

Clear header from the message.

Parameters
string$headerName
Returns
Zend_Mail Provides fluent inter
clearMessageId ( )

Clears the Message-ID from the message.

Returns
Zend_Mail Provides fluent interface
clearRecipients ( )

Clears list of recipient email addresses.

Returns
Zend_Mail Provides fluent interface
clearReplyTo ( )

Clears the current Reply-To address from the message.

Returns
Zend_Mail Provides fluent interface
clearReturnPath ( )

Clears the current Return-Path address from the message.

Returns
Zend_Mail Provides fluent interface
clearSubject ( )

Clears the encoded subject from the message.

Returns
Zend_Mail Provides fluent interface
createAttachment (   $body,
  $mimeType = Zend_Mime::TYPE_OCTETSTREAM,
  $disposition = Zend_Mime::DISPOSITION_ATTACHMENT,
  $encoding = Zend_Mime::ENCODING_BASE64,
  $filename = null 
)

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
string$body
string$mimeType
string$disposition
string$encoding
string$filenameOPTIONAL A filename for the attachment
Returns
Zend_Mime_Part Newly created Zend_Mime_Part object (to allow advanced settings)
createMessageId ( )

Creates the Message-ID.

Returns
string
getBodyHtml (   $htmlOnly = false)

Return Zend_Mime_Part representing body HTML.

Parameters
bool$htmlOnlyWhether to return the body HTML only, or the MIME part; defaults to false, the MIME part
Returns
false|Zend_Mime_Part|string
getBodyText (   $textOnly = false)

Return text body Zend_Mime_Part or string.

Parameters
booltextOnly Whether to return just the body text content or the MIME part; defaults to false, the MIME part
Returns
false|Zend_Mime_Part|string
getCharset ( )

Return charset string.

Returns
string
getDate ( )

Returns the formatted date of the message.

Returns
string
static getDefaultFrom ( )
static

Returns the default sender of the mail.

Returns
null|array Null if none was set.
static getDefaultReplyTo ( )
static

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

Returns
null|array Null if none was set.
static getDefaultTransport ( )
static

Gets the default mail transport for all following uses of unittests.

Todo:

Allow passing a string to indicate the transport to load

Allow passing in optional options for the transport to load

getEncodingOfHeaders ( )

Return encoding of mail headers.

Deprecated:
use getHeaderEncoding() instead
Returns
string
getFrom ( )

Returns the sender of the mail.

Returns
string
getHeaderEncoding ( )

Return the encoding of mail headers.

Either Zend_Mime::ENCODING_QUOTEDPRINTABLE or Zend_Mime::ENCODING_BASE64

Returns
string
getHeaders ( )

Return mail headers.

Returns
void
getMessageId ( )

Returns the Message-ID of the message.

Returns
string
getMimeBoundary ( )

Return the boundary string used for the message.

Returns
string
getPartCount ( )

Return a count of message parts.

Returns
integer
getRecipients ( )

Return list of recipient email addresses.

Returns
array (of strings)
getReplyTo ( )

Returns the current Reply-To address of the message.

Returns
string|null Reply-To address, null when not set
getReturnPath ( )

Returns the current Return-Path address of the message.

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

Returns
string
getSubject ( )

Returns the encoded subject of the message.

Returns
string
getType ( )

Get content type of the message.

Returns
string
send (   $transport = null)

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
Zend_Mail_Transport_Abstract$transport
Returns
Zend_Mail Provides fluent interface
setBodyHtml (   $html,
  $charset = null,
  $encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE 
)

Sets the HTML body for the message.

Parameters
string$html
string$charset
string$encoding
Returns
Zend_Mail Provides fluent interface
setBodyText (   $txt,
  $charset = null,
  $encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE 
)

Sets the text body for the message.

Parameters
string$txt
string$charset
string$encoding
Returns
Zend_Mail Provides fluent interface
setDate (   $date = null)

Sets Date-header.

Parameters
timestamp | string | Zend_Date$date
Returns
Zend_Mail Provides fluent interface
Exceptions
Zend_Mail_Exceptionif called subsequent times or wrong date format.
See Also
Zend_Mail_Exception
Zend_Mail_Exception
Zend_Mail_Exception
static setDefaultFrom (   $email,
  $name = null 
)
static

Sets Default From-email and name of the message.

Parameters
string$email
stringOptional $name
Returns
void
static setDefaultReplyTo (   $email,
  $name = null 
)
static

Sets Default ReplyTo-address and -name of the message.

Parameters
string$email
stringOptional $name
Returns
void
static setDefaultTransport ( Zend_Mail_Transport_Abstract  $transport)
static

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

Todo:

Allow passing a string to indicate the transport to load

Allow passing in optional options for the transport to load

Parameters
Zend_Mail_Transport_Abstract$transport
setEncodingOfHeaders (   $encoding)

Set the encoding of mail headers.

Deprecated:
Use setHeaderEncoding() instead.
Parameters
string$encoding
Returns
Zend_Mail
setFrom (   $email,
  $name = null 
)

Sets From-header and sender of the message.

Parameters
string$email
string$name
Returns
Zend_Mail Provides fluent interface
Exceptions
Zend_Mail_Exceptionif called subsequent times
See Also
Zend_Mail_Exception
setFromToDefaultFrom ( )

Sets From-name and -email based on the defaults.

Returns
Zend_Mail Provides fluent interface
setHeaderEncoding (   $encoding)

Set the encoding of mail headers.

Parameters
string$encodingZend_Mime::ENCODING_QUOTEDPRINTABLE or Zend_Mime::ENCODING_BASE64
Returns
Zend_Mail Provides fluent interface
See Also
Zend_Mail_Exception
setMessageId (   $id = true)

Sets the Message-ID of the message.

Parameters
boolean | string$idtrue :Auto false :No set null :No set string:Sets given string (Angle brackets is not necessary)
Returns
Zend_Mail Provides fluent interface
Exceptions
Zend_Mail_Exception
See Also
Zend_Mail_Exception
setMimeBoundary (   $boundary)

Set an arbitrary mime boundary for the message.

If not set, Zend_Mime will generate one.

Parameters
string$boundary
Returns
Zend_Mail Provides fluent interface
setReplyTo (   $email,
  $name = null 
)

Set Reply-To Header.

Parameters
string$email
string$name
Returns
Zend_Mail
Exceptions
Zend_Mail_Exceptionif called more than one time
See Also
Zend_Mail_Exception
setReplyToFromDefault ( )

Sets ReplyTo-name and -email based on the defaults.

Returns
Zend_Mail Provides fluent interface
setReturnPath (   $email)

Sets the Return-Path header of the message.

Parameters
string$email
Returns
Zend_Mail Provides fluent interface
Exceptions
Zend_Mail_Exceptionif set multiple times
See Also
Zend_Mail_Exception
setSubject (   $subject)

Sets the subject of the message.

Parameters
string$subject
Returns
Zend_Mail Provides fluent interface
Exceptions
Zend_Mail_Exception
See Also
Zend_Mail_Exception
setType (   $type)

Set content type.

Should only be used for manually setting multipart content types.

Parameters
string$typeContent type
Returns
Zend_Mail Implements fluent interface
Exceptions
Zend_Mail_Exceptionfor types not supported by Zend_Mime
See Also
Zend_Mail_Exception

Member Data Documentation

$_bodyHtml = false
protected
$_bodyText = false
protected
$_charset = 'iso-8859-1'
protected
$_date = null
protected
$_defaultFrom
staticprotected
$_defaultReplyTo
staticprotected
$_defaultTransport = null
staticprotected
$_from = null
protected
$_headerEncoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE
protected
$_headers = array()
protected
$_messageId = null
protected
$_mimeBoundary = null
protected
$_recipients = array()
protected
$_replyTo = null
protected
$_returnPath = null
protected
$_subject = null
protected
$_to = array()
protected
$_type = null
protected
$hasAttachments = false