1 |
joko |
1.1 |
#!/usr/bin/perl |
2 |
|
|
|
3 |
|
|
# ========================================================================== |
4 |
|
|
# a simple mail filter done in perl with CPAN-module "Mail::Audit" |
5 |
|
|
# more to come ... |
6 |
|
|
# TODO: |
7 |
|
|
# - more sophisticated filtering |
8 |
|
|
# - configuration-comfort (use arrays and hashes, no "matching-code-worm") |
9 |
|
|
# - Html-Gui |
10 |
|
|
# 2001-12-05, amo@netfrag.org |
11 |
|
|
# ========================================================================== |
12 |
|
|
|
13 |
|
|
|
14 |
|
|
# variables have to be declared! |
15 |
|
|
use strict; |
16 |
|
|
|
17 |
|
|
# ---------------------------------------------------------- |
18 |
|
|
# declare and initialize some variables |
19 |
|
|
# these are mostly directories for routing our mail to |
20 |
|
|
my $HOME = "/home/amo/virtual/home/amo_mail/"; |
21 |
|
|
my $MAILDIR = "$HOME/Mail"; |
22 |
|
|
my $LOGFILE = "$MAILDIR/procmail.log"; |
23 |
|
|
my $LOCKFILE = "$HOME/.procmail.lockfile"; |
24 |
|
|
my $DEFAULT = "$MAILDIR/UNSORTED/Current/Inbox"; |
25 |
|
|
|
26 |
|
|
|
27 |
|
|
# ---------------------------------------------------------- |
28 |
|
|
# main |
29 |
|
|
# ---------------------------------------------------------- |
30 |
|
|
|
31 |
|
|
# cry for our "Auditor" |
32 |
|
|
use Mail::Audit; |
33 |
|
|
|
34 |
|
|
# "jump" into processing of new incoming mail and get a "handler" to this mail |
35 |
|
|
my $incoming = Mail::Audit->new; |
36 |
|
|
|
37 |
|
|
# - - - - - - - - - - - - - - - - - - - - |
38 |
|
|
# process mail |
39 |
|
|
# - - - - - - - - - - - - - - - - - - - - |
40 |
|
|
if ($incoming->to =~ /ilo\.de/) { |
41 |
|
|
$incoming->accept("$MAILDIR/SORTED/ilo.de/Current/Inbox"); |
42 |
|
|
} |
43 |
|
|
if ($incoming->to =~ /web\.de/) { |
44 |
|
|
$incoming->accept("$MAILDIR/SORTED/web.de/Current/Inbox"); |
45 |
|
|
} |
46 |
|
|
# - - - - - - - - - - - - - - - - - - - - |
47 |
|
|
|
48 |
|
|
# the default-handler: simply accept all mails and route them to "/var/spool/mail" |
49 |
|
|
# $incoming->accept(); |
50 |
|
|
|
51 |
|
|
# if you want to reject all mails coming through to here, do a ... |
52 |
|
|
# $incoming->reject; |
53 |
|
|
|
54 |
|
|
# catch all mails and route them to a "DEFAULT"-inbox |
55 |
|
|
$incoming->accept($DEFAULT); |