Path

ez components / documentation / api reference / 1.1.2 / mail


eZ Components 1.1.2

Mail: ezcMail

[ Tutorial ] [ Display-example ] [ Class tree ] [ Element index ] [ ChangeLog ] [ Credits ]

Class: ezcMail

The main mail class. [source]
You can use ezcMail together with the other classes derived from ezcMailPart to build email messages. When the mail is built, use the Transport classes to send the mail.
This example builds and sends a simple text mail message:
1.  $mail new ezcMail;
2.  $mail->from new ezcMailAddress'sender@example.com''Adrian Ripburger' );
3.  $mail->addTonew ezcMailAddress'receiver@example.com''Maureen Corley' ) );
4.  $mail->subject "Hi";
5.  $mail->body new ezcMailText"I just mail to say I love you!" );
6.  $transport new ezcMailTransportMta();
7.  $transport->send$mail );
You can also derive your own mail classes from this class if you have special requirements. An example of this is the ezcMailComposer class which is a convenience class to send simple mail structures and HTML mail.
There are several headers you can set on the mail object to achieve various effects:
  • Reply-To - Set this to an email address if you want people to reply to an address other than the from address.
  • Errors-To - If the mail can not be delivered the error message will be sent to this address.

Parents

ezcMailPart
   |
   --ezcMail

Descendents

Child Class Description
ezcMailComposer Convenience class for writing mail.

Constants

BASE64 = "base64" Base 64 encoding.
BINARY = "binary" Binary encoding.
EIGHT_BIT = "8bit" 8 bit encoding.
QUOTED_PRINTABLE = "quoted_printable" Quoted printable encoding.
SEVEN_BIT = "7bit" 7 bit encoding.

Properties

array(ezcMailAddress) read/write  $bcc
Contains an array of ezcMailaddress objects.
ezcMailPart read/write  $body
The body part of the message.
array(ezcMailAddress) read/write  $cc
Contains an array of ezcMailaddress objects.
ezcMailAddress read/write  $from
Contains the from address as an ezcMailaddress object.
string read  $messageId
The message ID of the message. Treat as read-only unless you're 100% sure what you're doing. Also accessible through the deprecated property messageID.
string read/write  $subject
Contains the subject of the e-mail. Use setSubject if you require a special encoding.
string read/write  $subjectCharset
The encoding of the subject.
integer read  $timestamp
The date/time of when the message was sent as Unix Timestamp.
array(ezcMailAddress) read/write  $to
Contains an array of ezcMailaddress objects.

Method Summary

public ezcMail __construct( )
Constructs an empty ezcMail object.
public void addBcc( $address )
Adds the ezcMailAddress $address to the list of 'bcc' recipients.
public void addCc( $address )
Adds the ezcMailAddress $address to the list of 'cc' recipients.
public void addTo( $address )
Adds the ezcMailAddress $address to the list of 'to' recipients.
public string generateBody( )
Returns the generated body part of this mail.
public string generateHeaders( )
Returns the generated headers for the mail.

Inherited Methods

From ezcMailPart :
public ezcMailPart ezcMailPart::__construct()
Constructs a new mail part.
public void ezcMailPart::appendExcludeHeaders()
The array $headers will be excluded when the headers are generated.
public string ezcMailPart::generate()
Returns the complete mail part including both the header and the body as a string.
public abstract string ezcMailPart::generateBody()
Returns the body of this part as a string.
public string ezcMailPart::generateHeaders()
Returns the headers set for this part as a RFC 822 string.
public string ezcMailPart::getHeader()
Returns the RAW value of the header $name.
public void ezcMailPart::setHeader()
Sets the header $name to the value $value.
public void ezcMailPart::setHeaders()
Adds the headers $headers.

Methods

__construct

ezcMail __construct( )
Constructs an empty ezcMail object.

Redefinition of

Method Description
ezcMailPart::__construct() Constructs a new mail part.

Redefined in descendants as

Method Description
ezcMailComposer::__construct() Constructs an empty ezcMailComposer object.

addBcc

void addBcc( ezcMailAddress $address )
Adds the ezcMailAddress $address to the list of 'bcc' recipients.

Parameters

Name Type Description
$address ezcMailAddress  

addCc

void addCc( ezcMailAddress $address )
Adds the ezcMailAddress $address to the list of 'cc' recipients.

Parameters

Name Type Description
$address ezcMailAddress  

addTo

void addTo( ezcMailAddress $address )
Adds the ezcMailAddress $address to the list of 'to' recipients.

Parameters

Name Type Description
$address ezcMailAddress  

generateBody

string generateBody( )
Returns the generated body part of this mail.
Returns an empty string if no body has been set.

Redefinition of

Method Description
ezcMailPart::generateBody() Returns the body of this part as a string.

generateHeaders

string generateHeaders( )
Returns the generated headers for the mail.
This method is called automatically when the mail message is built. You can re-implement this method in subclasses if you wish to set different mail headers than ezcMail.

Redefinition of

Method Description
ezcMailPart::generateHeaders() Returns the headers set for this part as a RFC 822 string.

Last updated: Thu, 01 Nov 2007