procmail
[Top] [All Lists]

Re: Phantom lines in empty body

2004-06-21 17:20:07
On Sun, Jun 20, 2004 at 02:59:19PM -0700, Jim Osborn wrote:

Using this recipe to detect an empty mail body:

Just to add to the fun, here's a pair of recipes that I've found very handy:

    EOL="($)"
    DQ='"'
    WSPC="      "       # (space and tab)
    ST_MARKER="X-spamtrap:"

    ## text/plain is empty
    :0 fhw
    * $     
^Content-Type:[$WSPC]*multipart/[a-z]+;?[$WSPC]+boundary=[$DQ]?\/[^$DQ]+
    * $ B ?? ^--$\MATCH$EOL(\
           (.+$EOL)*\
           Content-Type:[$WSPC]+text/plain.*$EOL\
           (.+$EOL)*\
         )\
         ([$WSPC]*$EOL)*\
        ^--$\MATCH(--)?$EOL
    | formail -A "$ST_MARKER text/plain block is empty"

    ## text/plain is comment-only
    :0 Efhw
    * $     
^Content-Type:[$WSPC]*multipart/[a-z]+;?($EOL[$WSPC]+)?[$WSPC]*boundary=[$DQ]?\/[^$DQ]+
    * $ B ?? ^--$\MATCH$EOL(\
           (.+$EOL)*\
           Content-Type:[$WSPC]+text/plain.*$EOL\
           (.+$EOL)*\
         )\
         ([$WSPC]*$EOL)*\
         <!--$EOL?\
         ([a-z0-9'-]+ +)+$EOL\
         !-->$EOL\
         ([$WSPC]*$EOL)*\
        ^--$\MATCH(--)?$EOL
    | formail -A "$ST_MARKER text/plain block is comment-only"

There are some inconsistencies that don't appear to matter -- for
example, I'm pretty sure that single quotes are permitted around
boundaries, but I've never seen any.  YMMV.

This is modelled after something someone on this list came up with ...
ooh, some time in 2002 I think.  Wish I could remember who to credit.  :)

I can't help with your scoring troubles.

-- 
  Paul Chvostek                                             
<paul(_at_)it(_dot_)ca>
  Operations / Abuse / Whatever
  it.canada, hosting and development                   http://www.it.ca/


____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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