I\'m looking for good/working/simple to use php code for parsing raw email into parts.
I\'ve written a couple of brute force solutions, but every time, one small cha
There is a library for parsing raw email message into php array - http://flourishlib.com/api/fMailbox#parseMessage.
The static method parseMessage() can be used to parse a full MIME email message into the same format that fetchMessage() returns, minus the uid key.
$parsed_message = fMailbox::parseMessage(file_get_contents('/path/to/email'));
Here is an example of a parsed message:
array(
'received' => '28 Apr 2010 22:00:38 -0400',
'headers' => array(
'received' => array(
0 => '(qmail 25838 invoked from network); 28 Apr 2010 22:00:38 -0400',
1 => 'from example.com (HELO ?192.168.10.2?) (example) by example.com with (DHE-RSA-AES256-SHA encrypted) SMTP; 28 Apr 2010 22:00:38 -0400'
),
'message-id' => '<4BD8E815.1050209@flourishlib.com>',
'date' => 'Wed, 28 Apr 2010 21:59:49 -0400',
'from' => array(
'personal' => 'Will Bond',
'mailbox' => 'tests',
'host' => 'flourishlib.com'
),
'user-agent' => 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.9) Gecko/20100317 Thunderbird/3.0.4',
'mime-version' => '1.0',
'to' => array(
0 => array(
'mailbox' => 'tests',
'host' => 'flourishlib.com'
)
),
'subject' => 'This message is encrypted'
),
'text' => 'This message is encrypted',
'decrypted' => TRUE,
'uid' => 15
);