--- nfo/perl/scripts/dispatchmail/recieveMail 2002/10/21 12:03:53 1.1 +++ nfo/perl/scripts/dispatchmail/recieveMail 2002/10/21 12:16:31 1.2 @@ -1,27 +1,32 @@ #!/usr/bin/perl # ========================================================================== -# a simple mail filter done in perl with CPAN-module "Mail::Audit" -# more to come ... -# TODO: -# - more sophisticated filtering -# - configuration-comfort (use arrays and hashes, no "matching-code-worm") -# - Html-Gui -# 2001-12-05, amo@netfrag.org +# +# recieveMail v0.02 +# +# 2001-12-05, joko@netfrag.org +# a simple mail filter done in perl with CPAN-module "Mail::Audit" +# more to come ... +# TODO: +# - more sophisticated filtering +# - configuration-comfort (use arrays and hashes, no "matching-code-worm") +# - Html-Gui +# +# 2002-07-17, joko@netfrag.org +# + added filtering by target (looks in "to", "cc" and "bcc") +# # ========================================================================== - -# variables have to be declared! use strict; # ---------------------------------------------------------- # declare and initialize some variables # these are mostly directories for routing our mail to -my $HOME = "/home/amo/virtual/home/amo_mail/"; +my $HOME = "/home/joko/virtual/home/joko_mail/"; my $MAILDIR = "$HOME/Mail"; my $LOGFILE = "$MAILDIR/procmail.log"; my $LOCKFILE = "$HOME/.procmail.lockfile"; -my $DEFAULT = "$MAILDIR/UNSORTED/Current/Inbox"; +my $DEFAULT = "$MAILDIR/SORTED/misc/Inbox"; # ---------------------------------------------------------- @@ -37,12 +42,59 @@ # - - - - - - - - - - - - - - - - - - - - # process mail # - - - - - - - - - - - - - - - - - - - - - if ($incoming->to =~ /ilo\.de/) { - $incoming->accept("$MAILDIR/SORTED/ilo.de/Current/Inbox"); + + sub compareTarget { + my $pattern = shift; + my $ok = 0; + $ok = 1 if ($incoming->to =~ m/$pattern/); + $ok = 1 if ($incoming->cc =~ m/$pattern/); + $ok = 1 if ($incoming->bcc =~ m/$pattern/); + return $ok; + } + + # ----- + # source-routing + #if ($incoming->from =~ /root\@smtp\.f7x\.net/i) { + # $incoming->accept("$MAILDIR/SORTED/netfrag.org/Current/status-ns1.f7x.net"); + #} + if ($incoming->from =~ /(root|admin)\@cashew\.netfrag\.org/i) { + $incoming->accept("$MAILDIR/SORTED/netfrag.org/Status/cashew.netfrag.org"); + } + if ($incoming->from =~ /(root|admin)\@quepasa\.netfrag\.org/i) { + $incoming->accept("$MAILDIR/SORTED/netfrag.org/Status/quepasa.netfrag.org"); + } + if ($incoming->from =~ /(root|service|netsaint)\@h1\.service\.netfrag\.org/i) { + $incoming->accept("$MAILDIR/SORTED/netfrag.org/Status/h1.service.netfrag.org"); + } + + + # ----- + # source && destination - routing + if ($incoming->from =~ /andreas\.motl\@ilo\.de/ && compareTarget('joko\@netfrag\.org')) { + $incoming->accept("$MAILDIR/SORTED/netfrag.org/Info"); + } + + + # ----- + # destination-routing + my $bool_ilo = ($incoming->to =~ m/ilo\.de/i); + my $bool_ilo_news1 = ($incoming->to =~ m/kritletter\@kbx\.de/i); + my $bool_from_kolumnen_de = ($incoming->to =~ m/kolumnen\.de/i); + my $bool_from_strixner = ($incoming->to =~ m/strixner\@web\.de/i); + if ($bool_ilo || $bool_ilo_news1 || $bool_from_kolumnen_de || $bool_from_strixner) { + $incoming->accept("$MAILDIR/SORTED/ilo.de/Inbox"); } - if ($incoming->to =~ /web\.de/) { + + if ($incoming->to =~ /web\.de/i) { $incoming->accept("$MAILDIR/SORTED/web.de/Current/Inbox"); } + if ($incoming->to =~ /wor\.net/i) { + $incoming->accept("$MAILDIR/SORTED/wor.net/Current/Inbox"); + } + if ($incoming->to =~ /netfrag\.org/i || $incoming->to =~ /archivists-talk\@yahoogroups\.com/) { + $incoming->accept("$MAILDIR/SORTED/netfrag.org/Inbox"); + } + # - - - - - - - - - - - - - - - - - - - - # the default-handler: simply accept all mails and route them to "/var/spool/mail"