procmail
[Top] [All Lists]

Re: RECIPE: strip/remove ads from hotmail/yahoo originated messages

2002-03-27 13:22:34
At 10:42 2002-03-27 -0800, Aaron Smith did say:

This method will also strip reply-chained ads, so "> > > Do You Yahoo!?"
is killed as well.

FTR, you're going to run into trouble unless you ensure that you skip this on cryptographically signed messages.

I tackled this same thing several months ago (for a mailing list preprocessor), but I did it in a more centralized fashion, expressly avoiding the need for external scripting:

:0
* ^From:.*@([^ ]\.)*\/((excite|lycos|yahoo|(hot|rocket)mail|etc|juno)\.com\>|usa\.net\>|yahoo\.co\.uk)
{
        :0
        * MATCH ?? ^^(yahoo|rocketmail)
        {
STRING=" *DO YOU YAHOO(\!|)\?" # do not include opening left anchor DIVIDER=1 # to remove divider line above $STRING as well
        }
        :0E
        * MATCH ?? ^^hotmail
        {
                STRING="Get your FREE download of MSN Explorer at http:"
                DIVIDER=1
        }

        :0E
        * MATCH ?? ^^juno
        {
                STRING="GET INTERNET ACCESS FROM JUNO!"
                DIVIDER=1
        }

        :0E
        * MATCH ?? ^^usa
        {
STRING="Get free e-mail and a permanent address at http://www.amexmail.com/";
                DIVIDER=1
        }

        :0E
        * MATCH ?? ^^lycos
        {
                STRING="Get 250 color business cards for FREE\!"
                DIVIDER=0
        }

        :0E
        * MATCH ?? ^^excite
        {
                STRING="http://www.bluemountain.com/giftcenter/";
                DIVIDER=2
        }

        :0E # then we shouldn't be in this outer brace
        {
                ESCAPE=on
        }

        :0
        * ! ESCAPE ?? ^^on^^
        {
                # copy the footer into $MATCH
                # if you want the strippage to apply to previous posts
                # (which could trim text that follows a quote), remove the
                # caret from the condition.
                :0B
                * $ ^()\/$STRING(.*$)*^^
                {
                }

                # if you don't have head, use      sed "$= q"
:0Bbfwi # do not use `r' flag here if you will be saving in mbox format!
                * 1^1 ^.*$
                * -1^1 MATCH ?? ^.*$
                * $ -${DIVIDER:-0}^0
                | head -$=
        }

        ESCAPE # unset for other uses
}

---
 Sean B. Straw / Professional Software Engineering

 Procmail disclaimer: <http://www.professional.org/procmail/disclaimer.html>
 Please DO NOT carbon me on list replies.  I'll get my copy from the list.

_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail