Forwarding emails with a PHP script

We have a cron'ed PHP script that checks an inbox every ten minutes. The purpose of this script is to handle "STOP to quit" functionality for our SMS notification service we provide. If the script finds any emails with the word "STOP" at the beginning of the email, we remove the user from our notification database.

To cover our bases, we'd like any emails that don't meet the above criteria to be forwarded on to another email address (which is an alias) that several people receive and check hourly. However, we're running into problems forwarding the emails from this PHP script.

Knowing how the mail function of PHP works, it's quite obvious we need to reinsert the headers before mailing. However, MIME multipart emails always get sent as a garble of text, including the barriers and any base64 encoded attachments.

Does anyone know of a simple way to take an email message and forward it on properly using a PHP script?

We're using the native IMAP functions built in to PHP 5. We also have access to the PEAR Mail module. However, we have been unable to find any examples or people doing similar tasks by searching Google.

8
задан Michael Irigoyen 15 January 2011 в 05:20
поделиться