I am currently piping mail to a script that does a bit of parsing as per this article:
Email piped to the script gets recorded as $email. The script then parses it like this:
I want to parse $email more completely. I want to isolate fully the message body and email addresses, and ideally also isolate the message from any text that comprises a message to which the message body is a reply. (Ultimately I hope to handle attachments.)
I assume I will either need to use regular expressions or some existing function that must exist somewhere for parsing mail. If the former, then I will need help devising robust expressions that handle all possibilities. If the latter, I may need some help getting the function operating properly.
I’ll consider my question completely answered if I can get my script to handle everything except saving attachments (one thing at a time).
In a perfect world, some function would take $email as its argument and returns variables $to, $from, $subject, $message, $num_attachments, and $attachments_array with the array indicating the name, type, size and filepath of each attachment saved by the function (which saves each attachment to a specified directory if this attachment meets the size, type and number criteria).
Is there some library I can install that has such a function? Searching around I found some software called ripMIME that looks interesting (http://www.pldaniels.com/ripmime/
), but I am not sure that is what I want and it doesn’t appear to come with any documentation. Also I’ve never needed to install a library before.
Thanks for your help.