|Don't ask to ask, just ask|
Use Mail::MboxParser for extracting body textby jlongino (Parson)
|on Sep 02, 2002 at 17:31 UTC||Need Help??|
In my recent mail-munging experiments, I found that the easiest way to get the simple mail info was to use Mail::MboxParser. This won't directly help with the e-mail address problem (which can probably be done via regex) but it should help in most cases with the message body. I'm a novice at regexp, so I'll leave that part for someone more qualified.
The problem is that depending on the client software used, it may be possible to send a message with an HTML only message body by preference settings. Here is an example that will extract the plaintext body message if one exists. Note that this can be used to read single or multiple messages:
Just remember to handle errors/warnings for fields that are undefined.
You might check this node for an example of how to select only text attachments when dealing with multi-part MIME messages.
Update1: After a bit of R&R (reflection & research), I figured it would be best to mention a few things about the To: field format. I probably shouldn't have mentioned using a regexp to scarf the real e-mail address. Check out the documentation for RFC822 for details about the various ways header fields can be formatted. Things like folding and multiple addresses in the To: field to name a few.
One option that may prove worth looking at is Email::Valid , from the docs:
This would do what you need for a simple single address but you would still have to figure out a way to parse multiple addresses. Maybe someone else knows of another module or method for the address field problem.