|
Posted by "Geoff" on 01/20/06 00:22
Nobody got any ideas on this? I would be interested to hear from
anyone who has successfully adjusted parts of an email message while
it is in transit, by ANY method. I'm getting desparate and will try
anything, even if it is not 100% PHP.
All ideas, suggestions greatly appreciated.
Geoff.
------- Forwarded message follows -------
From: Geoff <php-general@2yd.com>
To: php-general@lists.php.net
Subject: inserting text into a mime message
Date sent: Thu, 19 Jan 2006 10:51:37 +0200
Hi All,
I've been searching the archives for help on this, but have come up
empty-handed. Here's the thing:
I'm using a PHP script to parse every message coming through a
mailserver. The server invokes my script for each message, giving it
a filename containing the full raw text of the email. The script
needs to modify the raw message file, inserting a footer (some
trailing text, eg: a disclaimer) at the end of each part of readable
message. It doesn't touch file attachments, but it needs to insert
the footer in any plaintext, HTML text or both (if they exist).
There are so many different mime options and encoding types that it
seemed like re-inventing the wheel to try working with only the raw
message text, so instead I decided to use the PEAR Mail_mimeDecode
module, which returns a very nice object array of all the parts,
decoded and ready for use.
It's no problem going through this and inserting the footer wherever
it is needed. That much I've done.
My problem is trying to rebuild that object array (the output of the
Mail_mimeDecode::decode() function) back into its raw form once
again, so that I can write the modified raw text back to the message
file and the email can go on its way.
Another complication is that except for the insertion of the footer,
I cannot modify the original message. All the headers, dates,
receive-paths, etc, must remain unchanged.
Has anybody ever done anything like this before - re-encoding a
message that had been decoded by Mail_mimeDecode::decode()? I've
looked at the encode() function, but it seems to be used for making
a simple message from scratch (with just one body part), it is not
really the opposite of decode(). [I may be wrong about this - there
are no examples in the PEAR manual].
I'm not hung up about what to use, it doesn't have to be PEAR, I
will use any library or code that will do the job. Alternatively, if
it is possible to do this with encode(), I would love to see an
example, as I couldn't get it to work that way myself.
Many thanks.
Geoff.
------- End of forwarded message -------
Navigation:
[Reply to this message]
|