Mail: ezcMailComposer
[ ]
[ ]
[ ]
[ ]
[ ]
Class: ezcMailComposer
|
Convenience class for writing mail. [
source]
This class allows you to create text and/or HTML mail with attachments. If you need to create more advanced mail use the ezcMail class and build the body from scratch.
ezcMailComposer is used with the following steps:
- Create a composer object.
- Set the subject and recipients.
- Set the plainText and htmlText message parts. You can set only one
or both. If you set both, the client will display the htmlText if it
supports HTML. Otherwise the client will display plainText.
- Add any attachments.
- Call the build method.
This example shows how to send an HTML mail with a text fallback and attachments. The HTML message has an inline image.
1. $mail = new ezcMailComposer();
2. $mail->from = new ezcMailAddress( 'john@doe.com', 'John Doe' );
3. $mail->addTo( new ezcMailAddress( 'cindy@doe.com', 'Cindy Doe' ) );
4. $mail->subject = "Example of an HTML email with attachments";
5. $mail->plainText = "Here is the text version of the mail. This is displayed if the client can not understand HTML";
6. $mail->htmlText = "<html>Here is the HTML version of your mail with an image: <img src='file://path_to_image.jpg' /></html>";
7. $mail->addAttachment( 'path_to_attachment.file' );
8. $mail->build();
9. $transport = new ezcMailTransportMta();
10. $transport->send( $mail );
This class has the following properties:
- string plainText, contains the message of the mail in plain text.
- string htmlText, contains the message of the mail in HTML. You should
also provide the text of the HTML message in the
plainText property. Both will be sent and the receiver
will see the HTML message if his/her client supports HTML.
If the HTML message contains links to local images and/or
files these will be included into the mail when
generateBody is called. Links to local files must start
with "file://" in order to be recognized.
Parents
ezcMailPart
|
--ezcMail
|
--ezcMailComposer
Inherited Constants
From
ezcMail:
Method Summary
|
public ezcMailComposer |
__construct(
)
Constructs an empty ezcMailComposer object. |
|
public void |
addAttachment(
$fileName )
Adds the file $fileName to the list of attachments. |
|
public void |
build(
)
Builds the complete email message in RFC822 format. |
|
public mixed |
__get(
$name )
Returns the property $name. |
|
public void |
__set(
$name, $value )
Sets the property $name to $value. |
Inherited Methods
From
ezcMail :
From
ezcMailPart :
Methods
__construct
ezcMailComposer __construct(
)
Constructs an empty ezcMailComposer object.
Redefinition of
addAttachment
void addAttachment(
string
$fileName )
Adds the file $fileName to the list of attachments.
Parameters
| Name |
Type |
Description |
$fileName |
string |
|
Throws
| Class | Description |
ezcBaseFileNotFoundException |
if $fileName does not exists. |
ezcBaseFilePermissionProblem |
if $fileName could not be read. |
build
void build(
)
Builds the complete email message in RFC822 format.
This method must be called before the message is sent.
Throws
| Class | Description |
ezcBaseFileNotFoundException |
if any of the attachment files can not be found. |
__get
mixed __get(
string
$name )
Returns the property $name.
Parameters
| Name |
Type |
Description |
$name |
string |
|
Throws
| Class | Description |
ezcBasePropertyNotFoundException |
if the property does not exist. |
Redefinition of
__set
void __set(
string
$name, mixed
$value )
Sets the property $name to $value.
Parameters
| Name |
Type |
Description |
$name |
string |
|
$value |
mixed |
|
Throws
| Class | Description |
ezcBasePropertyNotFoundException |
if the property does not exist. |
Redefinition of
Last updated: Thu, 31 Jan 2008