troubleshooting Question

seeking optimal way to parse an email sent to my PHP script via PIPE

Avatar of bitt3n
bitt3n asked on
PHP
21 Comments1 Solution3002 ViewsLast Modified:
I am currently piping mail to a script that does a bit of parsing as per this article:

http://www.devarticles.com/c/a/PHP/Incoming-Mail-and-PHP/1/

Email piped to the script gets recorded as $email. The script then parses it like this:

http://www.filefarmer.com/2/bitt3n/example.html

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.
ASKER CERTIFIED SOLUTION
sjohnstone1234

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 21 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 21 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros