
Retrieves and deletes messages from a email account via IMAP or POP3
All headers, text and html content returned by this class are encoded in UTF-8. Please see http://flourishlib.com/docs/UTF-8 for more information.
1.0.0b18 | Fixed a bug in fetchMessageSource() where IMAP connections would add an extra \r\n to the end of the source 9/16/12 |
---|---|
1.0.0b17 | Updated the class to be more forgiving when parsing the response for STATUS and FETCH IMAP commands 9/15/12 |
1.0.0b16 | Added method fetchMessageSource() 9/15/12 |
1.0.0b15 | Fixed handling of bounces with no headers 9/15/12 |
1.0.0b14 | Added a workaround for iconv having issues in MAMP 1.9.4+ 7/26/11 |
1.0.0b13 | Fixed handling of headers in relation to encoded-words being embedded inside of quoted strings 7/26/11 |
1.0.0b12 | Enhanced the error checking in write() 6/3/11 |
1.0.0b11 | Added code to work around PHP bug #42682 (http://bugs.php.net/bug.php?id=42682) where stream_select() doesn't work on 64bit machines from PHP 5.2.0 to 5.2.5, improved connectivity error handling and timeouts while reading data 1/10/11 |
1.0.0b10 | Fixed parseMessage() to properly handle a header format edge case and properly set the text and html keys even when the email has an explicit Content-disposition: inline header 11/25/10 |
1.0.0b9 | Fixed a bug in parseMessage() that could cause HTML alternate content to be included in the inline content array instead of the html element 9/20/10 |
1.0.0b8 | Fixed parseMessage() to be able to handle non-text/non-html multipart parts that do not have a Content-disposition header 9/18/10 |
1.0.0b7 | Fixed a typo in read() 9/7/10 |
1.0.0b6 | Fixed a typo from 1.0.0b4 7/21/10 |
1.0.0b5 | Fixes for increased compatibility with various IMAP and POP3 servers, hacked around a bug in PHP 5.3 on Windows 6/22/10 |
1.0.0b4 | Added code to handle emails without an explicit Content-type header 6/4/10 |
1.0.0b3 | Added missing static method callback constants 5/11/10 |
1.0.0b2 | Added the missing enableDebugging() 5/5/10 |
1.0.0b | The initial implementation 5/5/10 |
Adds an S/MIME certificate, or certificate + private key pair for verification and decryption of S/MIME messages
void addSMIMEPair( string $email_address, fFile|string $certificate_file, fFile $private_key_file=NULL, string $private_key_password=NULL )
string | $email_address | The email address the certificate or private key is for |
fFile|string | $certificate_file | The file the S/MIME certificate is stored in - required for verification and decryption |
fFile | $private_key_file | The file the S/MIME private key is stored in - required for decryption only |
string | $private_key_password | The password for the private key |
Parses a MIME message into an associative array of information
The output includes the following keys:
And one or more of the following:
All values in headers, text and body will have been decoded to UTF-8. Files in the attachment, inline and related array will all retain their original encodings.
array parseMessage( string $message, boolean $convert_newlines=FALSE )
string | $message | The full source of the email message |
boolean | $convert_newlines | If \r\n should be converted to \n in the text and html parts the message |
The parsed email message - see method description for details
Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code
Resets the configuration of the class
void reset( )
Configures the connection to the server
Please note that the GMail POP3 server does not act like other POP3 servers and the GMail IMAP server should be used instead. GMail POP3 only allows retrieving a message once - during future connections the email in question will no longer be available.
fMailbox __construct( string $type, string $host, string $username, string $password, integer $port=NULL, boolean $secure=FALSE, integer $timeout=NULL )
string | $type | The type of mailbox, 'pop3' or 'imap' |
string | $host | The server hostname or IP address |
string | $username | The user to log in as |
string | $password | The user's password |
integer | $port | The port to connect via - only required if non-standard |
boolean | $secure | If SSL should be used for the connection - this requires the openssl extension |
integer | $timeout | The timeout to use when connecting |
Disconnects from the server
void __destruct( )
Closes the connection to the server
void close( )
Deletes one or more messages from the server
Passing more than one UID at a time is more efficient for IMAP mailboxes, whereas POP3 mailboxes will see no difference in performance.
void deleteMessages( integer|array $uid )
integer|array | $uid | The UID(s) of the message(s) to delete |
Sets if debug messages should be shown
void enableDebugging( boolean $flag )
boolean | $flag | If debugging messages should be shown |
Retrieves a single message from the server
The output includes the following keys:
And one or more of the following:
All values in headers, text and body will have been decoded to UTF-8. Files in the attachment, inline and related array will all retain their original encodings.
array fetchMessage( integer $uid, boolean $convert_newlines=FALSE )
integer | $uid | The UID of the message to retrieve |
boolean | $convert_newlines | If \r\n should be converted to \n in the text and html parts the message |
The parsed email message - see method description for details
Retrieves the raw source of a single message from the server
This method is primarily useful for storing the raw source of a message. Normal use of fMailbox would involved calling fetchMessage(), which calls this method and then parseMessage().
string fetchMessageSource( integer $uid )
integer | $uid | The UID of the message to retrieve |
The raw message source of the email
Gets a list of messages from the server
The structure of the returned array is:
array(
(integer) {uid} => array(
'uid' => (integer) {a unique identifier for this message on this server},
'received' => (string) {date message was received},
'size' => (integer) {size of message in bytes},
'date' => (string) {date message was sent},
'from' => (string) {the from header value},
'subject' => (string) {the message subject},
'message_id' => (string) {optional - the message-id header value, should be globally unique},
'to' => (string) {optional - the to header value},
'in_reply_to' => (string) {optional - the in-reply-to header value}
), ...
)
All values will have been decoded to UTF-8.
array listMessages( integer $limit=NULL, integer $page=NULL )
integer | $limit | The number of messages to retrieve |
integer | $page | The page of messages to retrieve |
A list of messages on the server - see method description for details