procmail
[Top] [All Lists]

Recipe processing

2001-10-16 06:49:58
Hmm, there is this _advanced_ recipe that I've tried to modify in my favour 
without
success. Yes, it's quite advanced even for my understanding but I believed it 
was
gonna be useful for me, so I've been trying.....and whatever I try for


#DO SOMETHING will never work for me.

#### advanced recipe ##

        LOGFILE=logfile
        # extract the Subject without using an outside command
        :0
        * ^Subject:[    ]*\/[^  ](.*[^  ])?
        { }
        subject = "Subject: RE: $MATCH"

        # Variables for convenience and efficiency
        from = "From: Odhiambo Washington <wash(_at_)wananchi(_dot_)com>"
        to = `formail -rt -xTo: | sed -e 's/[;\`\\]/ /g' | expand | sed -e 
's/^[ ]*//g' -e 's/[ ]*$//g'`

        # Generate a reply header
        :0 hw
        * ! ^FROM_DAEMON
        header=| formail -r -I"$from" -I"$to" -I"$subject"

        # This doesn't correctly handle comments in the header fields
        :0
        * ^Mime-Version:[       ]*1\.0
        * ^Content-Type:[       ]*multipart.*;\/.*
        * MATCH ?? boundary[    ]*=[    ]*\/.*
        {
                boundary = $MATCH

                # Strip quotes from the boundary.  This should handle
                # backslashes, but it doesn't
                :0
                * boundary ?? ^^"\/.*[^"]
                { boundary = $MATCH }

                # Regexps for things in the body.  We have to handle header
                # field continuations manually, matching on newlines that
                # are followed by whitespace.
                dotstar = ".*(^[        ].*)*"
                ws = "[         ]*(^[   ]+)*"
                
                # Zero or more header fields in the body
                headerfields = "^(.+:$dotstar^)*"

                # The header fields whose values we check for name=
                CTDheader = "Content-(Type|Disposition):"

                # The actual regexp for matching that header field
                target = "${CTDheader}${dotstar}name${ws}=${dotstar}\.doc

                # Look for a boundary, followed by zero or more header
                # fields and the header field value that we're targetting
                :0 B
                * $ ^--$\boundary${headerfields}${target}
                {
                # DO SOMETHING HERE
                :0 abcw
                | ( echo "$header" ; \
                    cat "/home/wash/.LOG/.hate-ms-doc" ; \
                    echo "The e-mail you sent is attached below" ; \
                    echo "" ; \
                    echo "~~~~~~~~~~~~ begin returned mail ~~~~~~~~~~" ; \
                    expand | sed -e 's/[ ]*$//g' -e 's/^/ /' \
                  ) | $SENDMAIL $SENDMAILFLAGS -t

                # Always save a copy
                :0:
                MICROSUCK

                }
        }


And my logfile says:

wash(_at_)ns2 ('tty') ~/Test 356 -> less logfile 
procmail: Skipped "e"
procmail: Skipped "-mail you sent is attached below" ; \"
procmail: Skipped """ ; \"
procmail: Skipped ""~~~~~~~~~~~~ begin returned mail ~~~~~~~~~~" ; \"
procmail: Skipped "| sed -e 's/[ ]*$//g' -e 's/^/ /' \"
procmail: Skipped ") | $SENDMAIL $SENDMAILFLAGS -t"
From mnyokabi(_at_)wananchi(_dot_)com Tue Oct 16 14:12:58 2001
 Subject: Test 2
  Folder: MICROSUCK


Can someone please help me????


Thanking you.


-Wash

--
                                              ~\\_                 
 Odhiambo Washington                            \\\\               
 Wananchi Online Ltd.,                          `\\\\\             
 1st Flr Loita Hse, Loita Street                 |\\\\\            
 PO Box 10286,00100-NAIROBI,KE.                   \\\\\|__.--~~\   
 Fax: 254 2 313985-9                           _--~            /   
 Fax: 254 2 313922                           /~ //////  _-~~~~'    
 E-mail: wash(_at_)wananchi(_dot_)com                  ('-//////-//           
 URL    : http://www.wananchi.com            //////(((-)           
 GSM: 254 72 743 223 / 254 733 744 121     /////"                  
                                        _///"                      

+++
... Let me tell you who the actual "front-runners" are.  On one side,
you have George Bush, who is currently going through a sort of
fraternity hazing wherein he has to perform a series of humiliating
stunts to win the approval of the Republican Right.  For example, they
had him make a speech oozing praise all over William Loeb, deceased
publisher of the Manchester (N.H.) Union Leader and Slime Journalist.
Loeb had dumped viciously all over George in the 1980 New Hampshire
primary.  But when the Right held a big tribute for Loeb, George came
back to the fold, like a man with a bungee cord wrapped around his
neck.
                -- Dave Barry, "The Twinkie and the Squid"

Attachment: pgph6YcEqukiV.pgp
Description: PGP signature

<Prev in Thread] Current Thread [Next in Thread>