1 |
#!/usr/bin/perl |
#!/usr/bin/perl |
2 |
|
|
3 |
# ========================================================================== |
# ============================================================ |
4 |
# |
# |
5 |
# recieveMail v0.04 |
# dispatchmail v0.05 |
6 |
# a simple mail filter done in perl with CPAN-module "Mail::Audit" |
# A simple mail filter done in perl |
7 |
|
# with the Perl-module "Mail::Audit" |
8 |
|
# available from CPAN. |
9 |
# |
# |
10 |
|
# $Id$ |
11 |
# |
# |
12 |
# 2002-11-09, joko@netfrag.org |
# ============================================================ |
13 |
# + recieveMail now can run globally (/etc/mail/smrsh!) |
# $Log$ |
14 |
# + $HOME is taken from $ENV{HOME} or $ENV{PWD} |
# Revision 1.2 2003/01/22 05:38:44 collector |
15 |
# + rules are taken from $HOME/Mail/.rules.pm |
# + prepared refactoring to 'dispatchmail' |
|
# + fallback mechanism(s) |
|
|
# + bugfixes |
|
|
# |
|
|
# 2002-10-14, joko@netfrag.org |
|
|
# + $LOGFILE is used now (recievemail.log) |
|
|
# + tracing (uses $LOGFILE) |
|
|
# + checks delivery path for existance, |
|
|
# changes $LOGFILE if needed |
|
|
# |
|
|
# 2002-07-17, joko@netfrag.org |
|
|
# + added filtering by target (destination-routing) |
|
|
# (looks in "to", "cc" and "bcc") |
|
|
# |
|
|
# 2001-12-05, joko@netfrag.org |
|
|
# + initial internal release |
|
|
# |
|
|
# |
|
|
# TODO: |
|
|
# - more sophisticated filtering |
|
|
# - configuration-comfort (use perl-arrays and -hashes for rule-declaration) |
|
|
# - Html-Gui to add/edit/remove rules |
|
|
# - rule base located in LDAP (local delivery routing) |
|
|
# - completely hide away regex-stuff and provide simpler wildcarding |
|
|
# - hide needed quoting of dots (.) and ats (@) in addresses |
|
|
# - provide: beginsWith(string), endsWith(string), beginsAt(string, pos|regex) |
|
|
# - this could become a CPAN-module sometimes (?): |
|
|
# - "String"-Object to be inherited from gives these methods to you |
|
|
# - examples: |
|
|
# - routeTo("mbox:/path/to/mbox") if $to->beginsWith("hello"); |
|
|
# - routeTo("fax:+4930123456") if $subject->contains("gatefax"); |
|
|
# - metadata: |
|
|
# - add some info about the context we are running in: |
|
|
# - console |
|
|
# - sendmail/normal |
|
|
# - sendmail/smrsh |
|
|
# - add some info about the user we are doing this for: |
|
|
# - username |
|
|
# - home-directory |
|
|
# |
|
|
# WISHLIST: |
|
|
# - format basic log-output similar to procmail.log |
|
|
# - introduce some "extended logging" including the chosen routing path |
|
16 |
# |
# |
17 |
# ========================================================================== |
# ============================================================ |
18 |
|
|
19 |
use strict; |
use strict; |
20 |
# don't use warnings; |
# don't use warnings; |
51 |
my $HOME = $opt_base; |
my $HOME = $opt_base; |
52 |
my $MAILDIR = "$HOME/Mail"; |
my $MAILDIR = "$HOME/Mail"; |
53 |
my $LOGFILE = "$MAILDIR/recievemail.log"; |
my $LOGFILE = "$MAILDIR/recievemail.log"; |
54 |
my $RULESFILE = "$MAILDIR/.rules.pm"; |
my $RULESFILE = "$HOME/.recievemailrc.pm"; |
55 |
my $LOCKFILE = "$HOME/.procmail.lockfile"; |
my $LOCKFILE = "$HOME/.procmail.lockfile"; |
56 |
my $DEFAULT = "$MAILDIR/Inbox"; |
my $DEFAULT = "$MAILDIR/Inbox"; |
57 |
my $DEBUG = 0; |
my $DEBUG = 0; |
74 |
|
|
75 |
# 0.a. pre flight tracing |
# 0.a. pre flight tracing |
76 |
if ($TRACE) { |
if ($TRACE) { |
77 |
|
s2f("-" x 80); |
78 |
s2f("Mail from " . gchomp($incoming->from) . " to " . gchomp($incoming->to)); |
s2f("Mail from " . gchomp($incoming->from) . " to " . gchomp($incoming->to)); |
79 |
s2f("Subject: " . gchomp($incoming->subject)); |
s2f("Subject: " . gchomp($incoming->subject)); |
80 |
} |
} |