First: thanks for proving this class alowing people to decode mime mail without Pear.
I was working on some content checking to filter out unwanted mail and noticed that in a testmail (sent from outlook via exchange) some returned header fields where empty.
(I used var_export ($decoded[$message]); instead of var_dump($decoded[$message]); in test_message_decoder.php)
Looking at the raw mailfile I found that in the From: and Return-Path: fields the text between the quotes was missing.
Returning empty field data:
I have to add that browsing thrue the headers of lots of mail in my mailbox I could not find any header that had the working format for the Return-Path field.
It seems that when the (in this example) quoted part of these fiels is empty the class does not check if it can retrieve the content between the "<>".
(I also noticed that there is an extra trailing space returned by the class when there is data in front of the <> data in the two mentioned fields.)
In addition you may notice that "Lastname, Firstname" isn't an email address but (in this case) the name as displayed in the outlook addressbook.
In fact I'm wondering how to e.g. return an email with a header like this to the originator using the return or from data if the mail is rejected by my script.
Worst case I won't get any address data from the class and even when the quoted part exists it's possibly the addressbook name instead of the email address.
Any tips on how to proceed and access the data between <> in the two address fieds?
Manuel Lemos - 2007-05-17 16:31:17 - In reply to message 1 from Mario Huizinga
The return address is not necessarily passed in the message. That address is only informed to the receiving SMTP server during message transmission. Since you only get the headers, you need to rely on the from: header .
Currently this class does not decode headers to extract e-mail addresses from their values. That feature will be included in a future release.
Alternatively, the MIME composing and sending message class has a private function named GetRFC822Addresses that you can use to extract addresses from header values.
It is a private function, so it may change or even be removed. So, I recommend that you copy the copy the function code to your application so it is always there.
Manuel Lemos - 2007-05-18 22:16:53 - In reply to message 3 from Mario Huizinga
If you are using var_dump to display the parsed message results in an HTML page, keep in mind that the browser may assume that anything between < and > is a tag and so not display any data between those characters.
It seems that if the first character is +, your browser does not interpret what is inside < > as an HTML tag.
Use HtmlSpecialChars function to encode < > to display it in an HTML page.