views:

356

answers:

4

Are there any handy general items you put in your .procmailrc file?

+4  A: 

Just simple things - move messages to appropriate folders, forward some stuff to an email2sms address, move spam to spam folder. One thing I'm kind of proud of is how to mark your spam as "read" (this is for Courier IMAP and Maildir, where "read" means "move to different folder and change the filename"):

:0                                                                              
* ^X-Spam                       # the header our filter inserts for spam                                                                   
{                                                                               
    :0                                                                         
    .Junk\ E-mail/              # stores in .Junk E-mail/new/                                                                                      

    :0                                                                          
    * LASTFOLDER ?? /\/[^/]+$   # get the stored message's filename                                                   
    { tail=$MATCH }             # and put it into $tail
    # now move the message                                                            
    TRAP="mv .Junk\ E-mail/new/$tail .Junk\ E-mail/cur/$tail:2,S"               
}
Marie Fischer
+4  A: 

Many mailers prefix a mail's subject with "Re: " when replying, if that prefix isn't already there. German Outlook instead prefixes with "AW: " (for "AntWort") if that prefix isn't already there. Unfortunately, these two behaviours clash, resulting in mail subjects like "Re: AW: Re: AW: Re: AW: Re: AW: Lunch". So I now have:

:0f
* ^Subject: (Antwort|AW):
|sed -r -e '1,/^$/s/^(Subject: )(((Antwort: )|(Re: )|(AW: ))+)(.*)/\1Re: \7\nX-Orig-Subject: \2\7/'

Which curtails these (and an "Antwort: " prefix that I've evidently also been bothered by at some point) down to a single "Re: ".

Jon Bright
+1  A: 

To stop weird russian and chinese spams, I use this procmail configuration.

UNREADABLE='[^?"]*big5|iso-2022-jp|ISO-2022-KR|euc-kr|gb2312|ks_c_5601-1987'
:0:
* ^Content-Type:.*multipart
* B ?? $ ^Content-Type:.*^?.*charset="?($UNREADABLE)
spam-unreadable
hoyhoy
As much as I like all the answers, this one I found particularly useful. Also this is probably my first question from when SO was beta, so I apologize for asking a "not-one-answer" question.
dlamblin
+2  A: 

I have various filters in my .procmailrc file, but the most useful is this one, which I add to the very top of the file before I make any other changes.

:0 c:
mail.save

This saves a copy of everything and then continues with the rest of the recipes. If I've done something wrong, my e-mail is saved in the file "mail.save". When I'm sure my changes are working, I comment these lines out, until the next time.

--
bmb

bmb