Well I was working on this all day yesterday and I finally got it to work!

Lets say you are sending out a newsletter or something to people in your DB. Chances are you are going to get some bounces. Now, why would you do nothing with these bounced emails? You should unsubscribe them from your DB or something! Here's how to do it:

Step 1: Make a php file and call it whatever you want.
Step 2: Paste the following code into it:

On line 21/22, make sure that text appears in a bounced email. It may be different for everyone else

On line 23, change the subject to whatever the subject is of the outgoing email you sent

Code an action where it says //do action here. this could be a mysql query, or even writing it to a text document for later use

Step 4: In cpanel, go to "Account Level Filtering", click Create New Filter.
Name it whatever you like, then set up how you want them filtered. I set it up as "Subject Equals: Mail delivery failed: returning message to sender"

Step 5: Under Actions, click pipe to program, and put this:

Quote:

/usr/bin/php -q /home/USERNAME/public_html/FILE.php

Be sure to change "username" to your account, and "FILE" to whatever you named the php file.

Step 6: Testing and fixing! There is only one problem with the code above, on line 26 you see 2 numerical values.. This is what deletes extra characters from the substring. When you change the start and ending limiters to fir your needs, the numbers will be off. Just play around with the numbers until you get no extra characters (or any accidentally deleted characters) at the end or beginning of the email!

Step 7: Save everything! It will now be working. Please note that "testing" the filter does not work correctly, and nothing will happen why you try to do so. If you really want to test it, send an email to your main account with the title filter you chose and the same body as a bounced email and see if it works! Also, there may be a better way to strip the email out of the email, so be my guest to change it and let me know! You might be able to pass a header when you're sending your emails to make your life a little easier.

Thanks would be appreciated :D Please let me know of any customization to this script that make it easier to use! :)

10-26-2012, 12:03 AM

markman641

Bumping this! :3

10-31-2012, 11:28 PM

tangoforce

It should be noted that this will only work on linux where email piping is available. On windows it is not possible to use piping.