AnewtMailMessage Class Reference

Representation of an email message. More...

List of all members.

Public Member Functions

 __construct ()
 Initializes a new AnewtMailMessage instance.
 add_header ($name, $value)
 Adds a header to the message instance.
 get_header ($name)
 Returns the specified header.
 has_header ($name)
 Checks if a header is defined.
 send ($force=false)
 Sends the mail message.

Static Public Member Functions

static from_string ($data)
 Creates a new message by parsing a string containing a complete mail message.
static from_stream ($stream)
 Creates a new message by reading from a stream containing a complete mail message.
static from_file ($filename)
 Creates a new message by reading from a file containing a complete mail message.

Private Member Functions

 parse_body ($body)
 Parses the raw body of a message and stores the result in this message.
 parse_headers ($headers)
 Parses raw headers and stores them in this message.

Private Attributes

 $headers
 Object holding all header data.


Detailed Description

Representation of an email message.

This class provides both functionality for reading and sending email messages.

Todo:
Header/body formatting so that it can be used correctly to output a complete mail message.
Todo:
What to do with multipart messages?
Todo:
What to do with different encodings?

Definition at line 25 of file mailmessage.lib.php.


Member Function Documentation

static AnewtMailMessage::from_string ( data  )  [static]

Creates a new message by parsing a string containing a complete mail message.

The headers are parsed and stored; the body is left intact.

Parameters:
$data A string with a complete mail message
Returns:
A new AnewtMailMessage instance

Definition at line 39 of file mailmessage.lib.php.

static AnewtMailMessage::from_stream ( stream  )  [static]

Creates a new message by reading from a stream containing a complete mail message.

The headers are parsed and stored; the body is left intact.

Parameters:
$stream An open stream resource, eg. from fopen()
Returns:
A new AnewtMailMessage instance

Definition at line 72 of file mailmessage.lib.php.

static AnewtMailMessage::from_file ( filename  )  [static]

Creates a new message by reading from a file containing a complete mail message.

The headers are parsed and stored; the body is left intact.

Parameters:
$filename The filename of the file to read
Returns:
A new AnewtMailMessage instance

Definition at line 89 of file mailmessage.lib.php.

AnewtMailMessage::parse_body ( body  )  [private]

Parses the raw body of a message and stores the result in this message.

This method should only be called once during parsing. Bodies that are encoded using as 'quoted-printable' are converted to normal strings.

Parameters:
$body A string that contains the body text

Definition at line 130 of file mailmessage.lib.php.

AnewtMailMessage::add_header ( name,
value 
)

Adds a header to the message instance.

If the header already existed, the value is converted to an array and the new values is appended.

Parameters:
$name The name of the header
$value The value of the header

Definition at line 154 of file mailmessage.lib.php.

AnewtMailMessage::get_header ( name  ) 

Returns the specified header.

Parameters:
$name The name of the header
Returns:
A string containing the header value or an array containing multiple string values (if the header occurred more than once)

Definition at line 184 of file mailmessage.lib.php.

AnewtMailMessage::has_header ( name  ) 

Checks if a header is defined.

Parameters:
$name The name of the header
Returns:
True if the header was found, false otherwise

Definition at line 199 of file mailmessage.lib.php.

AnewtMailMessage::parse_headers ( headers  )  [private]

Parses raw headers and stores them in this message.

This method should only be called once during parsing.

Parameters:
$headers A string or array that contains the headers to be parsed

Ignore "^From .* if it's the first line (mbox)

Definition at line 211 of file mailmessage.lib.php.

AnewtMailMessage::send ( force = false  ) 

Sends the mail message.

This method tries to use the sendmail binary directly (falls back to the PHP mail() function) to actually send the message. Note that only messages which have the 'can-send' attribute set to true are considered for sending. Messages that were parsed from a file, stream or a string (using the static methods of this class) will have this attribute set to false, because sending a message you just parsed is not generally what you want.

Parameters:
$force Optional parameter to force sending of non-sendable messages
Returns:
True if the message was sent successfully, false if an error occurred
Todo:
Handle name/address rfc822 addresses correctly
Todo:
Include all headers instead of just a few

Definition at line 287 of file mailmessage.lib.php.


The documentation for this class was generated from the following file:

Generated on Sun Aug 2 22:54:38 2009 for Anewt by  doxygen 1.5.9