Path

ez components / documentation / api reference / 2009.1rc1 / mail


eZ Components 2009.1rc1

Mail: ezcMailPart

[ Tutorial ] [ Display example ] [ Mail listing example ] [ Rfcs ] [ Class tree ] [ Element index ] [ ChangeLog ] [ Credits ]

Class: ezcMailPart

Abstract base class for all mail MIME parts. [source]
This base class provides functionality to store headers and to generate the mail part. Implementations of this class must handle the body of that parts themselves. They must also implement generateBody() which is called when the message part is generated.

Descendents

Child Class Description
ezcMailRfc822Digest Mail part or mail digest parts.
ezcMailFilePart Mail part for all forms of binary data.
ezcMailText Mail part used for sending all forms of plain text.
ezcMailMultipart Abstract base class for all multipart types.
ezcMailDeliveryStatus Mail part used for sending delivery status message.
ezcMail The main mail class.

Properties

ezcMailContentDispositionHeader read/write  $contentDisposition
Contains the information from the Content-Disposition field of this mail. This useful especially when you are investigating retrieved mail to see if a part is an attachment or should be displayed inline. However, it can also be used to set the same on outgoing mail. Note that the ezcMailFile part sets the Content-Disposition field itself based on it's own properties when sending mail.
ezcMailHeadersHolder read  $headers
Contains the header holder object, taking care of the headers of this part. Can be retreived for reasons of extending this class and its derivals.
int read/write  $size
The size of the mail part in bytes. It is set when parsing a mail ezcMailParser->parseMail().

Member Variables

protected array(string=>mixed) $properties = array()
Holds the properties of this class.

Method Summary

public ezcMailPart __construct( )
Constructs a new mail part.
public void appendExcludeHeaders( $headers )
The array $headers will be excluded when the headers are generated.
public string generate( )
Returns the complete mail part including both the header and the body as a string.
public abstract string generateBody( )
Returns the body of this part as a string.
public string generateHeaders( )
Returns the headers set for this part as a RFC 822 string.
public string getHeader( $name )
Returns the RAW value of the header $name.
protected string getHeaderCharset( $name )
Returns the charset registered for the header $name.
public void setHeader( $name, $value, [$charset = 'us-ascii'] )
Sets the header $name to the value $value and its charset to $charset.
protected void setHeaderCharset( $name, [$value = 'us-ascii'] )
Sets the charset of the header $name to $value.
public void setHeaders( $headers )
Adds the headers $headers.

Methods

__construct

ezcMailPart __construct( )
Constructs a new mail part.

Redefined in descendants as

Method Description
ezcMailRfc822Digest::__construct() Constructs a new ezcMailDigest with the mail $mail.
ezcMailFilePart::__construct() Constructs a new attachment with $fileName.
ezcMailStreamFile::__construct() Constructs a new attachment with $fileName and $stream.
ezcMailVirtualFile::__construct() Constructs a new attachment with $fileName and $contents.
ezcMailFile::__construct() Constructs a new attachment with $fileName.
ezcMailText::__construct() Constructs a new TextPart with the given $text, $charset and $encoding.
ezcMailMultipart::__construct() Constructs a new ezcMailMultipart with the parts $parts.
ezcMailMultipartAlternative::__construct() Constructs a new ezcMailMultipartAlternative
ezcMailMultipartDigest::__construct() Constructs a new ezcMailMultipartDigest
ezcMailMultipartRelated::__construct() Constructs a new ezcMailMultipartRelated.
ezcMailMultipartReport::__construct() Constructs a new ezcMailMultipartReport.
ezcMailMultipartMixed::__construct() Constructs a new ezcMailMultipartMixed
ezcMailDeliveryStatus::__construct() Constructs a new DeliveryStatus part.
ezcMail::__construct() Constructs an empty ezcMail object.
ezcMailComposer::__construct() Constructs an empty ezcMailComposer object.

appendExcludeHeaders

void appendExcludeHeaders( $headers )
The array $headers will be excluded when the headers are generated.

Parameters

Name Type Description
$headers array(string)  

See also:

ezcMailPart::generateHeaders().


generate

string generate( )
Returns the complete mail part including both the header and the body as a string.

Redefined in descendants as

Method Description
ezcMailFilePart::generate() Override of the generate() method from ezcMailPart. Used to set headers before generating the part.

generateBody

string generateBody( )
Returns the body of this part as a string.
This method is called automatically by generate() and subclasses must implement it.

Redefined in descendants as

Method Description
ezcMailRfc822Digest::generateBody() Returns the body part of this mail consisting of the digested mail.
ezcMailStreamFile::generateBody() Returns the contents of the file with the correct encoding.
ezcMailVirtualFile::generateBody() Returns the contents of the file with the correct encoding.
ezcMailFile::generateBody() Returns the contents of the file with the correct encoding.
ezcMailText::generateBody() Returns the generated text body of this part as a string.
ezcMailMultipart::generateBody() Returns the generated body for all multipart types.
ezcMailDeliveryStatus::generateBody() Returns the generated text body of this part as a string.
ezcMail::generateBody() Returns the generated body part of this mail.

generateHeaders

string generateHeaders( )
Returns the headers set for this part as a RFC 822 string.
Each header is separated by a line break. This method does not add the required two lines of space to separate the headers from the body of the part.
It also encodes the headers (with the 'Q' encoding) if the charset associated with the header is different than 'us-ascii' or if it contains characters not allowed in mail headers.
This function is called automatically by generate() and subclasses can override this method if they wish to set additional headers when the mail is generated.

See also:

ezcMailPart::setHeader().

Redefined in descendants as

Method Description
ezcMailText::generateHeaders() Returns the headers set for this part as a RFC822 compliant string.
ezcMailDeliveryStatus::generateHeaders() Returns the headers set for this part as a RFC822 compliant string.
ezcMail::generateHeaders() Returns the generated headers for the mail.

getHeader

string getHeader( string $name )
Returns the RAW value of the header $name.
Returns an empty string if the header is not found. Getting headers is case insensitive. Getting the header 'Message-Id' will match both 'Message-ID' and 'MESSAGE-ID' as well as 'Message-Id'.
The raw value is MIME-encoded, so if you want to decode it, use ezcMailTools::mimeDecode() or implement your own MIME-decoding function.

Parameters

Name Type Description
$name string  

getHeaderCharset

string getHeaderCharset( string $name )
Returns the charset registered for the header $name.

Parameters

Name Type Description
$name string  

setHeader

void setHeader( string $name, string $value, [string $charset = 'us-ascii'] )
Sets the header $name to the value $value and its charset to $charset.
If the header is already set it will override the old value.
Headers set should be folded at 76 or 998 characters according to the folding rules described in RFC 2822.
If $charset is specified, it is associated with the header $name. It defaults to 'us-ascii' if not specified. The text in $value is encoded with $charset after calling generateHeaders().
Note: The header Content-Disposition will be overwritten by the contents of the contentsDisposition property if set.

Parameters

Name Type Description
$name string  
$value string  
$charset string  

See also:

ezcMailPart::generateHeaders().


setHeaderCharset

void setHeaderCharset( string $name, [string $value = 'us-ascii'] )
Sets the charset of the header $name to $value.
If $value is not specified it defaults to 'us-ascii'.

Parameters

Name Type Description
$name string  
$value string  

setHeaders

void setHeaders( $headers )
Adds the headers $headers.
The headers specified in the associative array $headers will overwrite any existing header values.
The array $headers can have one of these 2 forms:
  • array( header_name => header_value ) - by default the 'us-ascii' charset will be associated with all headers
  • array( header_name => array( header_value, header_charset ) ) - if header_charset is missing it will default to 'us-ascii'
Headers set should be folded at 76 or 998 characters according to the folding rules described in RFC 2822.

Parameters

Name Type Description
$headers array(string=>mixed)  

Last updated: Mon, 22 Jun 2009