Categories

Updated: 05/15/2008

EMAIL / MIME Parser (Decoder) in PHP

No other scripts (or classes) are required. Simply provide the script with a raw email in $email. The script will then parse the Headers in to &"To:&" &"From:&" &"Cc:&" and &"Bcc:&" and the Message in to Plain and HTML. If the email is non MIME, it will output the messgae as is. The attachments are assumed to be base64 encoded and will decode these and deposit them in the same directory as the script, keeping the original file name and extension. The directory can be changed by changing the $path variable. The script can easily be altered to handle other encoded attachments. This script is PHP4 and PHP5 compatible. For PHP5, it would be best to change some of the string funtions to non-case sensitive versions (e.g. change str_replace to str_ireplace, etc). The script has been tested on Outlook Express, Hotmail and Freeserve (Orange and Wanadoo).
©2019 A--9.com