Mail Class. More...
Public Member Functions | |
__construct ($from, $to, $subject="No Subject", $message=null, array $headers=array()) | |
Constructor. | |
addDestination ($to) | |
Add a destination to the mail. | |
removeDestination ($to) | |
Remove a destination. | |
setHeader ($header, $value) | |
Add an header. | |
setHeaderSeparator ($glue) | |
Set the header separator. | |
getSubject () | |
Subject getter. | |
setSubject ($subject) | |
Subject setter. | |
addMessagePart ($message, $content_type=null, $charset="utf-8") | |
Add a new part to the message. | |
addAttachment ($path, $content_type=null, $filename=null) | |
Attach a file to the mail. | |
removeMessagePart ($key) | |
Remove a message part. | |
removeAttachement ($key) | |
Alias of axMail::removeMessagePart() | |
send () | |
Send the mail. | |
__toString () | |
Get the message body as string. | |
Static Public Member Functions | |
static | validateEmail ($email) |
Validates email address. | |
Data Fields | |
const | HEADER_BCC = "Bcc" |
const | HEADER_CC = "Cc" |
const | HEADER_CONTENT_DESCRIPTION = "Content-Description" |
const | HEADER_CONTENT_TYPE = "Content-Type" |
const | HEADER_CONTENT_TRANSFERT_ENCODING = "Content-Transfer-Encoding" |
const | HEADER_DATE = "Date" |
const | HEADER_FROM = "From" |
const | HEADER_MIME_VERSION = "MIME-Version" |
const | HEADER_PRIORITY = "Priority" |
const | HEADER_REPLY_TO = "Reply-To" |
const | HEADER_SENDER = "Sender" |
const | HEADER_SUBJECT = "Subject" |
const | HEADER_TO = "To" |
const | HEADER_X_CONFIRM_READING_TO = "X-Confirm-Reading-To" |
const | HEADER_X_MAILER = "X-Mailer" |
const | HEADER_X_PRIORITY = "X-Priority" |
const | HEADER_X_UNSUBSCRIBE_EMAIL = "X-Unsubscribe-Email" |
const | HEADER_X_UNSUBSCRIBE_WEB = "X-Unsubscribe-Web" |
const | HEADER_SEPARATOR_CRLF = "\r\n" |
const | HEADER_SEPARATOR_LF = "\n" |
Static Public Attributes | |
static | $allowed_headers |
Allowed headers. | |
Protected Attributes | |
$_header_separator = self::HEADER_SEPARATOR_CRLF | |
Header separator. | |
$_from | |
Sender. | |
$_to = array() | |
Recipients. | |
$_subject | |
Subject. | |
$_message_parts = array() | |
Body parts. | |
$_headers = array() | |
Headers. |
Mail Class.
Definition at line 18 of file axMail.class.php.
axMail::__construct | ( | $ | from, |
$ | to, | ||
$ | subject = "No Subject" , |
||
$ | message = null , |
||
array $ | headers = array() |
||
) |
Constructor.
The @ $to parameter can be either a string representing one destination or an array representing multiple destinations. Headers passed to this method follows this format:
$header = array('<header_name>' => '<header_value>' ...)
Invalid headers names or values will trigger InvalidArgumentException.
string | $from | The sender |
array | $to | The recipient(s) |
string | $subject | [optional] [default "NO Subject" ] The subject |
string | $message | [optional] [default null ] The body (can be defined later) |
array | $headers | [optional] [default array() ] The headers (can be defined later) |
array | $options | [optional] [default array() ] TO BE IMPLEMENTED |
InvalidArgumentException | If the $from parameter is not a valid email |
Definition at line 114 of file axMail.class.php.
Get the message body as string.
Definition at line 416 of file axMail.class.php.
axMail::addAttachment | ( | $ | path, |
$ | content_type = null , |
||
$ | filename = null |
||
) |
Attach a file to the mail.
If the filename parameter is left empty, the file's name will be determined automaticaly. Returns the message part key (just like axMail::addMessagePart does)
string | $path | The file path |
string | $content_type | [optional] [default null ] The file's content type |
string | $filename | [optional] [default null ] Will be calculated from $path if null |
axMissingFileException | If the file cannot be found |
InvalidArgumentException | If the file is not a regular file (directory or link for instance) |
Definition at line 324 of file axMail.class.php.
axMail::addDestination | ( | $ | to | ) |
Add a destination to the mail.
InvalidArgumentException | If the destination is invalid. |
string | $to | The destination |
Definition at line 163 of file axMail.class.php.
axMail::addMessagePart | ( | $ | message, |
$ | content_type = null , |
||
$ | charset = "utf-8" |
||
) |
Add a new part to the message.
If the content type parameter is left to null, no header will be apended to the message part. This method will add a message part to the list and return the key (useful for part removal with axMail::removeMessagePart()).
string | $message | The part's body |
string | $content_type | [optional] [default null ] The part content type |
string | $charset | [optional] [default "utf-8" ] The part charset |
Definition at line 300 of file axMail.class.php.
axMail::removeAttachement | ( | $ | key | ) |
Alias of axMail::removeMessagePart()
string | $key |
Definition at line 374 of file axMail.class.php.
axMail::removeDestination | ( | $ | to | ) |
Remove a destination.
string | $to |
Definition at line 176 of file axMail.class.php.
axMail::removeMessagePart | ( | $ | key | ) |
Remove a message part.
string | $key |
Definition at line 364 of file axMail.class.php.
axMail::send | ( | ) |
Send the mail.
Returns an array where keys are destinations and values are booleans representing the send status.
RuntimeException | If called whith no mail body defined |
Definition at line 386 of file axMail.class.php.
axMail::setHeader | ( | $ | header, |
$ | value | ||
) |
Add an header.
Header must be part of axMail::$valid_headers. Value will be checked accordingly to each header and an InvalidArgumentException will be thrown in case of invalid value.
string | $header | The header |
scalar | $value | The header's value |
InvalidArgumentException | If the header or its value is invalid return axMail |
Definition at line 194 of file axMail.class.php.
axMail::setHeaderSeparator | ( | $ | glue | ) |
Set the header separator.
According to rfc1341, header has to be separated by a CRLF (
) but some mailboxes like Hotmail doesn't recognize it and expects a LF (
).
string $glue The separator InvalidArgumentException If the separator is not CRLF nor LF axMail
Definition at line 264 of file axMail.class.php.
axMail::setSubject | ( | $ | subject | ) |
Subject setter.
string | $subject |
Definition at line 284 of file axMail.class.php.
static axMail::validateEmail | ( | $ | ) | [static] |
Validates email address.
If possible, will check the dnsrr for the mail's host.
string | The mail address to validate |
Definition at line 143 of file axMail.class.php.
string axMail::$_from [protected] |
Sender.
Definition at line 69 of file axMail.class.php.
string axMail::$_header_separator = self::HEADER_SEPARATOR_CRLF [protected] |
Header separator.
Definition at line 63 of file axMail.class.php.
array axMail::$_headers = array() [protected] |
Headers.
Definition at line 93 of file axMail.class.php.
array axMail::$_message_parts = array() [protected] |
Body parts.
Definition at line 87 of file axMail.class.php.
string axMail::$_subject [protected] |
Subject.
Definition at line 81 of file axMail.class.php.
array axMail::$_to = array() [protected] |
Recipients.
Definition at line 75 of file axMail.class.php.
array axMail::$allowed_headers [static] |
array( self::HEADER_BCC, self::HEADER_CC, self::HEADER_CONTENT_DESCRIPTION, self::HEADER_CONTENT_TRANSFERT_ENCODING, self::HEADER_CONTENT_TYPE, self::HEADER_DATE, self::HEADER_FROM, self::HEADER_MIME_VERSION, self::HEADER_PRIORITY, self::HEADER_REPLY_TO, self::HEADER_SENDER, self::HEADER_SUBJECT, self::HEADER_TO, self::HEADER_X_CONFIRM_READING_TO, self::HEADER_X_MAILER, self::HEADER_X_PRIORITY, self::HEADER_X_UNSUBSCRIBE_WEB, self::HEADER_X_UNSUBSCRIBE_EMAIL )
Allowed headers.
Definition at line 50 of file axMail.class.php.
const axMail::HEADER_BCC = "Bcc" |
Definition at line 24 of file axMail.class.php.
const axMail::HEADER_CC = "Cc" |
Definition at line 25 of file axMail.class.php.
const axMail::HEADER_CONTENT_DESCRIPTION = "Content-Description" |
Definition at line 26 of file axMail.class.php.
const axMail::HEADER_CONTENT_TRANSFERT_ENCODING = "Content-Transfer-Encoding" |
Definition at line 28 of file axMail.class.php.
const axMail::HEADER_CONTENT_TYPE = "Content-Type" |
Definition at line 27 of file axMail.class.php.
const axMail::HEADER_DATE = "Date" |
Definition at line 29 of file axMail.class.php.
const axMail::HEADER_FROM = "From" |
Definition at line 30 of file axMail.class.php.
const axMail::HEADER_MIME_VERSION = "MIME-Version" |
Definition at line 31 of file axMail.class.php.
const axMail::HEADER_PRIORITY = "Priority" |
Definition at line 32 of file axMail.class.php.
const axMail::HEADER_REPLY_TO = "Reply-To" |
Definition at line 33 of file axMail.class.php.
const axMail::HEADER_SENDER = "Sender" |
Definition at line 34 of file axMail.class.php.
const axMail::HEADER_SEPARATOR_CRLF = "\r\n" |
Definition at line 43 of file axMail.class.php.
const axMail::HEADER_SEPARATOR_LF = "\n" |
Definition at line 44 of file axMail.class.php.
const axMail::HEADER_SUBJECT = "Subject" |
Definition at line 35 of file axMail.class.php.
const axMail::HEADER_TO = "To" |
Definition at line 36 of file axMail.class.php.
const axMail::HEADER_X_CONFIRM_READING_TO = "X-Confirm-Reading-To" |
Definition at line 37 of file axMail.class.php.
const axMail::HEADER_X_MAILER = "X-Mailer" |
Definition at line 38 of file axMail.class.php.
const axMail::HEADER_X_PRIORITY = "X-Priority" |
Definition at line 39 of file axMail.class.php.
const axMail::HEADER_X_UNSUBSCRIBE_EMAIL = "X-Unsubscribe-Email" |
Definition at line 40 of file axMail.class.php.
const axMail::HEADER_X_UNSUBSCRIBE_WEB = "X-Unsubscribe-Web" |
Definition at line 41 of file axMail.class.php.