Hey Steven:

On Mon, Mar 25, 2002 at 09:40:01AM -0800, Steven Walker wrote:

> I have PHP automated emails sent from my website. Does anybody know a 
> good way to filter returned mail? What I want to do is extract the bad 
> email addresses from returned mail and delete them from my database.

Are you familiar with Procmail?  If you're running on a unix type
system, this will be the best option.  Check out
http://www.zer0.org/procmail/mini-faq.html on how to use it.

Here's a quick sample recipe file I'll call "rc.bounce."  This has NOT
been tested and I'm basing it on some quick assumptions.  You're going
to have to tweak it to conform to your exact conditions.

   # egrep the 'H'eader.
   * ^From:.*<>
   | $HOME/bounce.php

Then, you'll have to write bounce.php to process the incoming mail 

If you don't have procmail, or you don't want to deal with it, you can
direct the returns to a particular mailspool file (aka mailbox).  Write
up a PHP script to parse the file, splitting it up into separate emails,
then gleaning the needed information from each email and update your
database with the relevant data.  Then, whenever you feel like
processing the bounces, run the script.

Here's a regex I use to split mail files (reassemble the linewraps, of

$Emails = preg_split("/[\n\r]+From\s*[^\s]*\s*
   \d{2}:\d{2}:\d{2} (19|20)\d{2}[\n\r]+/", $ContentString);



                PHP scripts that make your job easier
         SQL Solution  |  Layout Solution  |  Form Solution
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to