You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following patch provides improved bounce message parsing for fMailbox.
diff --git a/fMailbox.php b/fMailbox.php
index c223ec6..c1b4f0c 100644
--- a/fMailbox.php+++ b/fMailbox.php@@ -489,7 +489,11 @@ class fMailbox
*/
static private function parseHeaders($headers, $filter=NULL)
{
- $header_lines = preg_split("#\r\n(?!\s)#", trim($headers));+ $headers = trim($headers);+ if (!strlen($headers)) {+ return array();+ }+ $header_lines = preg_split("#\r\n(?!\s)#", $headers);
$single_email_fields = array('from', 'sender', 'reply-to');
$multi_email_fields = array('to', 'cc');
@@ -704,7 +708,7 @@ class fMailbox
static private function parseStructure($data, $headers=NULL)
{
if (!$headers) {
- list ($headers, $data) = explode("\r\n\r\n", $data, 2);+ list ($headers, $data) = preg_split("#^\r\n|\r\n\r\n#", $data, 2);
$headers = self::parseHeaders($headers);
}
@@ -1137,6 +1141,54 @@ class fMailbox
{
$this->connect();
+ $source = $this->fetchMessageSource($uid);++ $info = self::parseMessage($source, $convert_newlines);+ $info['uid'] = $uid;++ return $info;+ }+++ /**+ * Retrieves a single message from the server+ * + * The output includes the following keys:+ * + * - `'uid'`: The UID of the message+ * - `'received'`: The date the message was received by the server+ * - `'headers'`: An associative array of mail headers, the keys are the header names, in lowercase+ * + * And one or more of the following:+ * + * - `'text'`: The plaintext body+ * - `'html'`: The HTML body+ * - `'attachment'`: An array of attachments, each containing:+ * - `'filename'`: The name of the file+ * - `'mimetype'`: The mimetype of the file+ * - `'data'`: The raw contents of the file+ * - `'inline'`: An array of inline files, each containing:+ * - `'filename'`: The name of the file+ * - `'mimetype'`: The mimetype of the file+ * - `'data'`: The raw contents of the file+ * - `'related'`: An associative array of related files, such as embedded images, with the key `'cid:{content-id}'` and an array value containing:+ * - `'mimetype'`: The mimetype of the file+ * - `'data'`: The raw contents of the file+ * - `'verified'`: If the message contents were verified via an S/MIME certificate - if not verified the smime.p7s will be listed as an attachment+ * - `'decrypted'`: If the message contents were decrypted via an S/MIME private key - if not decrypted the smime.p7m will be listed as an attachment+ * + * 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.+ * + * @param integer $uid The UID of the message to retrieve+ * @param boolean $convert_newlines If `\r\n` should be converted to `\n` in the `text` and `html` parts the message+ * @return array The parsed email message - see method description for details+ */+ public function fetchMessageSource($uid)+ {+ $this->connect();+
if ($this->type == 'imap') {
$response = $this->write('UID FETCH ' . $uid . ' (BODY[])');
preg_match('#\{(\d+)\}$#', $response[0], $match);
@@ -1151,19 +1203,15 @@ class fMailbox
}
}
- $info = self::parseMessage($message, $convert_newlines);- $info['uid'] = $uid;+ return $message;
} elseif ($this->type == 'pop3') {
$response = $this->write('RETR ' . $uid);
array_shift($response);
$response = join("\r\n", $response);
- $info = self::parseMessage($response, $convert_newlines);- $info['uid'] = $uid;+ return $response;
}
-- return $info;
}
The text was updated successfully, but these errors were encountered:
The following patch provides improved bounce message parsing for fMailbox.
The text was updated successfully, but these errors were encountered: