Why not make it right in the first place...

This filter should get all attachments, and with reasonable cpu.
Simply copy into the global maildroprc or your ~/.mailfilter.
Maildrop has some issue about the location of ~/tmp (check your logs)
but hopefully someone will investigate and post a patch soon :)

Notes:
Maildrop wont match anything with the flag :w, two different lines
for header and body are necessary.


VERBOSE=3
PATH="/usr/lib/courier/bin"     # or wherever reformail resides

if ( /^content-type: !((multipart)|(application)).*![:space:]/:h )
{
  TYPE=$MATCH2
  EXTENSIONS="(vbs)|(scr)|(exe)|(com)|(pif)|(lnk)|(bat)"
  CONTENT="((content-)|([:space:])).*[:space:](file)?name="

  if ( $TYPE =~ /^multipart/ )  # grep body
  { 
    if( /^$CONTENT\"!.*\.($EXTENSIONS)!\"$/:b )
    {
      FILENAME=$MATCH2
    }
  }
  else  # grep header
  {
    if ( /^$CONTENT\"!.*\.($EXTENSIONS)!\"$/:h )
    {
      FILENAME=$MATCH2
    }
  }

  if ( "$FILENAME" )    # found something
  {
    echo "X-Content-Virus-Warning: $FILENAME"
    /^Subject: !.*/
    xfilter "reformail -A'X-Content-Filter: $TYPE $EXTENSIONS' \
                -A'X-Content-Virus-Warning: $FILENAME' \
                -I'Subject: [VIRUS WARNING: $FILENAME] $MATCH2'"
  }
  else  # debug only, comment out
  {
        echo "X-Content-Passed: $TYPE $EXTENSIONS"
        xfilter "reformail -A'X-Content-Passed: $TYPE $EXTENSIONS'"
  }

}

# ps: dont use this if you dont understand what it does...


_______________________________________________
courier-users mailing list
[EMAIL PROTECTED]
Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-users

Reply via email to