#!/usr/bin/perl use strict; use warnings; =pod =head1 SYNOPSIS mail-deliver I* =head1 DESCRIPTION Custom mail delivery agent. The spam tokens indicate potential spam detected upstream (by getmail, q.v.). TMDA catches all normal spam, but I subscribe to some lists that are poorly filtered. To do some light filtering then, I use getmail to scan message bodies together with this script (which has easy access to headers) to filter off the spam. See also /usr/local/libext/mail-deliver =cut use Mail::Procmail; sub _deliver_and_exit( $ ); # ( $box) # # Delivers to $ENV{HOME}/.mail/$box/, and never returns. # pm_init( logfile=> 'stderr', loglevel=> 1 ); # if( pm_gethdr( 'from' ) =~ /^Google Groups $/ ) # { # for my $spam_token( @ARGV ) # { # $spam_token eq 'google-groups-spam' and _deliver_and_exit( '_/junk' ); # } # } # Spam from job boards, on my B address. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # if( pm_gethdr( 'from' ) =~ /\bnewsletter\@jobseekerweekly\.com\b/ ) # { # _deliver_and_exit( '_/junk' ); # } # if( pm_gethdr( 'from' ) =~ /\bfarreachresumes\.com\b/ ) # { # _deliver_and_exit( '_/junk' ); # } # if( pm_gethdr( 'from' ) =~ /Defense Talent|\bdefensetalent\.com\b/ ) # { # _deliver_and_exit( '_/junk' ); # } # if( pm_gethdr( 'from' ) =~ /\bnewsletter\@career-digest\.com\b/ ) # { # _deliver_and_exit( '_/junk' ); # } # if( pm_gethdr( 'from' ) =~ /\bnewsletter\@jobmarketweekly\.com\b/ ) # { # _deliver_and_exit( '_/junk' ); # } # if( pm_gethdr( 'from' ) =~ /\bnewsletter\@thecareernews\.com\b/ ) # { # _deliver_and_exit( '_/junk' ); # } # Sort to lists and other subscriptions. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if( pm_gethdr( 'sender' ) eq 'owner-apsa_itp_at_lists_hmdc_harvard_edu@mail.hmdc.harvard.edu' ) { if( pm_gethdr( 'from' ) =~ /\bmike\@zelea\.com\b/ ) # echo from list server, of my own sent mail { _deliver_and_exit( '_/junk' ); } _deliver_and_exit( 'apsa_itp' ); } if( pm_gethdr( 'list-id' ) eq 'consult' ) { if( pm_gethdr( 'from' ) =~ /\bmike\@zelea\.com\b/ ) # echo from list server, of my own sent mail { _deliver_and_exit( '_/junk' ); } _deliver_and_exit( 'consult' ); } if( pm_gethdr( 'list-id' ) =~ m'\belection-methods-electorama\.com\b' ) { # if( pm_gethdr( 'from' ) =~ /\bmike\@zelea\.com\b/ ) # echo from list server, of my own sent mail # { # _deliver_and_exit( '_/junk' ); # } _deliver_and_exit( 'election-methods' ); } # if( pm_gethdr( 'x-lsv-listid' ) eq 'NCDD-DISCUSSION' ) if( pm_gethdr( 'list-owner' ) =~ /\bNCDD-DISCUSSION/ ) { # if( pm_gethdr( 'from' ) =~ /\bmike\@zelea\.com\b/ ) # echo from list server, of my own sent mail # { # _deliver_and_exit( '_/junk' ); # } _deliver_and_exit( 'ncdd-discussion' ); } if( pm_gethdr( 'list-id' ) =~ /\bopencitiesorganize\.googlegroups\.com\b/ ) { if( pm_gethdr( 'from' ) =~ /\bmike\@zelea\.com\b/ ) # echo from list server, of my own sent mail { _deliver_and_exit( '_/junk' ); } _deliver_and_exit( 'opencitiesorganize' ); } if( pm_gethdr( 'list-id' ) =~ /\bopenid4java\.googlegroups\.com\b/ ) { if( pm_gethdr( 'from' ) =~ /\bmike\@zelea\.com\b/ ) # echo from list server, of my own sent mail { _deliver_and_exit( '_/junk' ); } _deliver_and_exit( 'openid4java' ); } if( pm_gethdr( 'list-id' ) eq 'research' ) { if( pm_gethdr( 'from' ) =~ /\bmike\@zelea\.com\b/ ) # echo from list server, of my own sent mail { _deliver_and_exit( '_/junk' ); } _deliver_and_exit( 'research' ); } if( pm_gethdr( 'list-id' ) =~ m'\bstart_metagovernment\.org\b' ) { # if( pm_gethdr( 'from' ) =~ /\bmike\@zelea\.com\b/ ) # echo from list server, of my own sent mail # { # _deliver_and_exit( '_/junk' ); # } _deliver_and_exit( 'start' ); } if( pm_gethdr( 'list-id' ) =~ /\btextbender\.googlegroups\.com\b/ ) { if( pm_gethdr( 'from' ) =~ /\bmike\@zelea\.com\b/ ) # echo from list server, of my own sent mail { _deliver_and_exit( '_/junk' ); } _deliver_and_exit( 'textbender' ); } if( pm_gethdr( 'list-id' ) =~ /\btorcamp\.googlegroups\.com\b/ ) { if( pm_gethdr( 'from' ) =~ /\bmike\@zelea\.com\b/ ) # echo from list server, of my own sent mail { _deliver_and_exit( '_/junk' ); } _deliver_and_exit( 'torcamp' ); } if( pm_gethdr( 'list-id' ) =~ /\busers\.wicket\.apache\.org\b/ ) { if( pm_gethdr( 'from' ) =~ /\bmike\@zelea\.com\b/ ) # echo from list server, of my own sent mail { _deliver_and_exit( '_/junk' ); } _deliver_and_exit( 'users' ); } if( pm_gethdr( 'list-id' ) =~ /\bvotorola\.googlegroups\.com\b/ ) { if( pm_gethdr( 'from' ) =~ /\bmike\@zelea\.com\b/ ) # echo from list server, of my own sent mail { _deliver_and_exit( '_/junk' ); } _deliver_and_exit( 'votorola' ); } if( pm_gethdr( 'sender' ) =~ /\bWRITING-AND-THE-DIGITAL-LIFE\@JISCMAIL\.AC\.UK\b/ ) { _deliver_and_exit( 'writing-and-the-digital-life' ); } # - - - _deliver_and_exit( 'recent' ); # and exits ##### S u b - B o d y #################################################################### sub _deliver_and_exit( $ ) { my $box = shift; pm_deliver( "$ENV{HOME}/.mail/$box/" ); # and exits } __END__ if( pm_gethdr( 'from' ) =~ /\btrace\@ntu.ac.uk\b/ ) { pm_deliver( $ENV{HOME} . '/.mail/_/junk' ); # and exits } { my $address_pattern = 'fvwm(?:-request)?\@fvwm\.org'; if( $to_header =~ /$address_pattern/i || $cc_header =~ /$address_pattern/i || $from_header =~ /^$address_pattern$/i ) { pm_deliver( $ENV{HOME} . '/.mail/fvwm@fvwm.org/' ); # and exits } } if( $to_header =~ /forum\@XFree86\.Org/i || $cc_header =~ /forum\@XFree86\.Org/i || $from_header =~ /.*forum.*\@XFree86\.Org$/i ) { pm_deliver( $ENV{HOME} . '/.mail/forum@XFree86.Org/' ); # and exits } if( pm_gethdr( 'list-id' ) =~ /\bdarcs-users\.darcs\.net\b/ ) { _deliver_and_exit( 'list/darcs-users' ); } if( pm_gethdr( 'subject' ) =~ /^\[alexandria - / ) { _deliver_and_exit( 'alexandria' ); } if( pm_gethdr( 'list-id' ) =~ /\bjava-dev\.lists\.apple\.com\b/ ) { _deliver_and_exit( 'java-dev' ); }