Path

ez components / documentation / api reference / 1.0 / mail


eZ Components 1.0

Mail: ezcMail

[ Tutorial ] [ 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.
The ezcMail class has the following properties:
  • from ezcMailAddress, contains the from address as an ezcMailaddress object.
  • to array(ezcMailAddress), contains an array of ezcMailAddress objects.
  • cc array(ezcMailAddress), contains an array of ezcMailAddress objects.
  • bcc array(ezcMailAddress), contains an array of ezcMailAddress objects.
  • subject string, contains the subject of the e-mail. Use setSubject if you require a special encoding.
  • subjectEncoding string The encoding of the subject.
  • body ezcMailPart the body part of the message.
{@, describes the encoding of charactersets in header. }}

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.

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.
public mixed __get( $name )
Returns the property $name.
public void __set( $name, $value )
Sets the property $name to $value.

Inherited Methods

From ezcMailPart :
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 value of the header $name.
public void ezcMailPart::setHeader()
Sets the header $name to the value $value.

Methods

__construct

ezcMail __construct( )
Constructs an empty ezcMail object.

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.

__get

mixed __get( string $name )
Returns the property $name.

Parameters

Name Type Description
$name string  

Throws

ClassDescription
ezcBasePropertyNotFoundException if the property does not exist.

Redefined in descendants as

Method Description
ezcMailComposer::__get() Returns the property $name.

__set

void __set( string $name, mixed $value )
Sets the property $name to $value.

Parameters

Name Type Description
$name string  
$value mixed  

Throws

ClassDescription
ezcBasePropertyNotFoundException if the property does not exist.

Redefined in descendants as

Method Description
ezcMailComposer::__set() Sets the property $name to $value.

Last updated: Thu, 31 Jan 2008