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. :0H * ^To:.*[EMAIL PROTECTED] * ^From:.*<> | $HOME/bounce.php Then, you'll have to write bounce.php to process the incoming mail accordingly. 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 course): $Emails = preg_split("/[\n\r]+From\s*[^\s]*\s* (Mon|Tue|Wed|Thu|Fri|Sat|Sun)\s* (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s*\d{1,2} \d{2}:\d{2}:\d{2} (19|20)\d{2}[\n\r]+/", $ContentString); Enjoy, --Dan -- PHP scripts that make your job easier http://www.analysisandsolutions.com/code/ 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