procmail
[Top] [All Lists]

Re: filter on attachments

2005-02-07 23:58:40
At 22:45 2005-02-07 -0500, Technical Support wrote:
I want to set up my procmail so that all mail that comes into my address FOO(_at_)BAR(_dot_)COM that has any attachment what-so-ever is automatically forwarded to a new account NEW(_at_)BAR(_dot_)COM(_dot_) I am new to procmail and not sure how to do this. Can someone help me with this?

In the .procmailrc for the account foo(_at_)example(_dot_)com (the poor sod who owns bar.com must get a LOT of spam...):

:0
* 9876543210^0 ^Content-Type:[  ]*multipart/mixed
* 9876543210^0 B ?? ^Content-Type:[     ]*application
!new(_at_)example(_dot_)com

A few things to note though - procmail doesn't parse mime, so just because there's a Content-Type: in the body doesn't mean it's a VALID mime construct -- it could be an email discussing mail formatting (say, on this very list). The use of scoring (see 'man procmailsc') is to allow an explicit OR operation - either condition can match - both don't have to.

IME, the multipart/mixed in the message headers should catch most everything that has an "attachment" per-se -- HOWEVER, that includes some forms of HTML mail (though many of those should be multipart/alternative). If you wanted to increase the scope, eliminate the "/mixed" from the end of the condition line. The second, matching a content-type containing application should catch a number of program types specifically, but even those should normally arrive as a multipart/mixed at the outer MIME layer.

Run this in a sandbox against a corpus of received email messages and then check the ones which it might fail to match, and adjust as appropriate. I have _NOT_ tested it - this is just off the cuff.


---
 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 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>