Axiom (v1.2.0)

A lightweight PHP framework
axMail Class Reference

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.

Detailed Description

Mail Class.

Todo:
Mail class long description
Warning:
You may add as many parts as you want into the mail using axMail::addPart but keep the text part as first part.
This class has several bugs that needs to be fixed !
Author:
Delespierre
License:
http://www.gnu.org/licenses/lgpl.html Lesser General Public Licence version 3

Definition at line 18 of file axMail.class.php.


Constructor & Destructor Documentation

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.

Parameters:
string$fromThe sender
array$toThe 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
Exceptions:
InvalidArgumentExceptionIf the $from parameter is not a valid email

Definition at line 114 of file axMail.class.php.


Member Function Documentation

Get the message body as string.

Note:
This method will determine the type of mail and eventualy set its header to multipart/mixed if more than one part is found.
this method will set the from header for ease purpose.
Returns:
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)

Parameters:
string$pathThe 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
Exceptions:
axMissingFileExceptionIf the file cannot be found
InvalidArgumentExceptionIf the file is not a regular file (directory or link for instance)
Returns:
string

Definition at line 324 of file axMail.class.php.

Add a destination to the mail.

Exceptions:
InvalidArgumentExceptionIf the destination is invalid.
Parameters:
string$toThe destination
Returns:
void

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()).

Parameters:
string$messageThe part's body
string$content_type[optional] [default null] The part content type
string$charset[optional] [default "utf-8"] The part charset
Returns:
string

Definition at line 300 of file axMail.class.php.

Subject getter.

Returns:
string

Definition at line 275 of file axMail.class.php.

Alias of axMail::removeMessagePart()

See also:
axMail::removeMessagePart
Parameters:
string$key
Returns:
voic

Definition at line 374 of file axMail.class.php.

Remove a destination.

Parameters:
string$to
Returns:
void

Definition at line 176 of file axMail.class.php.

Remove a message part.

Parameters:
string$key
Returns:
void

Definition at line 364 of file axMail.class.php.

Send the mail.

Returns an array where keys are destinations and values are booleans representing the send status.

Exceptions:
RuntimeExceptionIf called whith no mail body defined
Returns:
array

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.

Note:
Any date value will be parsed using strtotime so make sure your dates apply to a well recognized format or simply set a timestamp.
Parameters:
string$headerThe header
scalar$valueThe header's value
Exceptions:
InvalidArgumentExceptionIf the header or its value is invalid return axMail

Definition at line 194 of file axMail.class.php.

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.

Parameters:
string$subject
Returns:
void

Definition at line 284 of file axMail.class.php.

static axMail::validateEmail ( email) [static]

Validates email address.

If possible, will check the dnsrr for the mail's host.

Parameters:
string$emailThe mail address to validate
Returns:
boolean

Definition at line 143 of file axMail.class.php.


Field Documentation

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]
Initial value:
 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.

Definition at line 43 of file axMail.class.php.

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.


The documentation for this class was generated from the following file:
 All Data Structures Files Functions Variables