What I would do is find the first text/plain part in the message, munge that and use it as the sole body in the outgoing message. the reason for that is you can be almost certain that the mail will contain a text/plain part and by removing all other parts you don't have to worry about ppl seeing them. If you need to munge every single part you have your work cut out for you. You could theoretically have a alternative part which is sound, not to mention mixed inside alternative inside mixed. And I have seen text/rtf inside a multipart/alternative
As for a full strategy I'd probably go OO style and make a object for each mime type which has functions for each of the actions you need to perform eg $txt->replace_string('foo', 'bar'). Then container types would call the functions on whatever they contain. Any type you don't have a handler for gets dropped from the message when you parse it in. So now your munging is basically $body->replace_string('foo', 'bar') and that's all in one place which just works on all the different types you support.
In reply to Re: Advice for email munging
by tedrek
in thread Advice for email munging
by Limbic~Region
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |