####################################################################### # Some basic filter rules for maildrop # ####################################################################### # # # I got most help and inspiration from the maildrop mailinglist. # # http://lists.sourceforge.net/lists/listinfo/courier-maildrop # # # Please browse the mailinglist archives for more examples. # # http://sourceforge.net/mailarchive/forum.php?forum=courier-maildrop # # # Look here for Sean Rima's .mailfilter file: # # http://www.dotfiles.com/files/18/238_.mailfilter # # # Some of the following rules are not tested! There may be syntax # errors and typos! # ################################################################# # Mark Weinem 9/2k2, mark.weinem@uni-duisburg.de # ################################################################# ####################################################################### # # Please note: # # - Save this file as .mailfilter in your home directory # and do # # chmod 600 .mailfilter # # # - Do not edit your .mailfilter file with a DOS or WINDOWS # texteditor!! # # # - Linebreaking doesn't work inside a pattern. So the following # rule cannot work: # # if (/^Subject:.*(exim|sendmail| \ # gdm|xdm|imap|cgi)/) # # and must be in one line: # # if (/^Subject:.*(exim|sendmail|gdm|xdm|imap|cgi)/) # # # - Linebreaking only works for quotet text and between patterns: # # "Imagine this is as a \ # long text string" # # # if (/^To:.*mutt/ \ # || /^[Cc][Cc]:.*mutt/) # ####################################################################### ##################################### # # Example 1: # Adding missing headers for PGP/MIME # ##################################### BPM="-----BEGIN PGP MESSAGE-----" EPM="-----END PGP MESSAGE-----" BPS="-----BEGIN PGP SIGNATURE-----" EPS="-----END PGP SIGNATURE-----" if (!/^Content-Type: message/ && !/^Content-Type: multipart/ \ && !/^Content-Type: application\/pgp/) { if (/^$BPM/:b && /^$EPM/:b) xfilter "reformail -A 'Content-Type: application/pgp; format=text; \ x-action=encrypt'" if (/^$BPS/:b && /^$EPS/:b) xfilter "reformail -A 'Content-Type: application/pgp; format=text; \ x-action=sign'" } ############################ # # Destination of the logfile # ############################ logfile $HOME/.maildroplog ######################################################### # # Example 2: # Adding a spam header to messages with numbered subjects # ######################################################### if (/^Subject:.*[:wbreak:][:digit:][:digit:][:digit:][:digit:][:wbreak:]/ \ && !/^Precedence: bulk/) { xfilter "reformail -A'X-Antispam: Numbered Subject'" } ######################################################## # # Example 3: # Adding a header to big messages, to mark them as spam # ######################################################## if($SIZE > 262144) { xfilter "reformail -A'X-Spam-Flag: YES'" } else { xfilter "reformail -A'X-Spam-Flag: NO SPAM'" } if ( /^X-Spam-Flag: YES/ ) { to "./Mail/.SPAM/" } else { xfilter "reformail -A'X-Test: Else works'" to "./Mail/tests/" } #################################################### # # Example 4: # Detecting spam mails running Spamassassin or Razor. # # If you use Spamassassin: # Make sure spamd is started when your system boots. # #################################################### ## 4.1 Spamassassin xfilter "/usr/bin/spamc" if (/^X-Spam-Flag: YES/) { to "./Mail/.SPAM/" } ## 4.2 Razor `/usr/bin/razor-check` if ( $RETURNCODE == 0 ) { xfilter "$REFORMAIL -A'X-Antispam: Razor Warning'" if (/^X-Antispam: Razor Warning/) { to "./Mail/.SPAM/" } } ################################### # # Example 5: # Correcting wrong signature dashes # ################################### if (/^--$/:b) { xfilter "sed -e 's/^--$/-- /'" log "Sig Dashes corrected" } ########################################### # # Example 6: # Extracting text of message body to a file # ########################################### if (/^Subject:.*Luebesbrief/) ( xfilter "sed '1,/^$/d' >textfile" } ############################################################# # # Example 7: # Delivering messages to an externel program: Autoresponding # # Use double quotes for variable substitution! # # !!!very untested!!! # ############################################################# if (/^Subject:.*info/) { to "|/usr/local/bin/mailbot \ -A \"X-Sender: $FROM\" -A \"From: $FROM\" \ -m \"./Maildir/autoresponses/testing\" \ /usr/bin/sendmail -t -f \"\"" } ############################################################### # # Example 8: # Filter messages that do not come from an uni-duisburg account # ############################################################### if (!/^From:.*uni-duisburg\.de/) { to Mail/private } ################################### # # Example 9: # Software I don't wanne read about. # ################################### if (/^Subject:.*(exim|sendmail|[x]?emacs|gdm|xdm|imap|cgi|[ ]?deb[ ])/) { to Mail/trash } ####################################### # # Example 10: # Trashing RAID[0-9] and Eterm messages # ####################################### if (/^Subject:.*[ ]raid[0-9]?$/) to Mail/trash if (/^Subject:.*[ ]raid[0-9]?[ ].*/) to Mail/trash if (/^Subject:raid[0-9]?[ ].*/) to Mail/trash if (/^Subject:.*[ ]eterm$/) to Mail/trash if (/^Subject:.*[ ]eterm[ ].*/) to Mail/trash if (/^Subject:eterm[ ].*/) to Mail/trash ############################ # # Example 11: # Trashing offtopic messages # ############################ if (/^Subject:.*(\[ot\]|\|\[off\]|\[.*[ ]ot\])|off.*topic/) { to Mail/trash } ######################### # # Example 12: # Trashing test messages # ######################### if (/^Subject:test$/) to Mail/trash if (/^Subject:.*[ ]test$/) to Mail/trash ################################# # # Example 13: # Delivering mailinglist messages # ################################# if (/^List-ID:.*freebsd-ports/) { if (/^Subject:.*(w3m|lyx|lynx|mutt|slrn|leafnode|getmail|maildrop|vim|wwwoffle)/) { to Mail/freebsd-updates } else { to Mail/freebsd-ports } } if (/^To:.*mutt/ || /^[Cc][Cc]:.*mutt/ \ || /^Mail-Followup-To:.*mutt/ || /^Subject:.*mutt/) { to Mail/mutt } ################################################ # # At last: # Collecting and storing E-mail addresses # from private messages (E-mails that # don't belong to mailinglists). # # Does not work with big messages. # # lbdb is the "little brother's datbase" program # ################################################ if ( $SIZE < 10000 ) cc "|lbdb-fetchaddr"