initial commit of file from CVS for smeserver-mailsorting on Sat Sep 7 19:56:19 AEST 2024
This commit is contained in:
35
root/etc/e-smith/templates-user/.mailfilter/00setup
Normal file
35
root/etc/e-smith/templates-user/.mailfilter/00setup
Normal file
@@ -0,0 +1,35 @@
|
||||
{
|
||||
# vim: ft=perl:
|
||||
|
||||
use esmith::AccountsDB;
|
||||
use esmith::ConfigDB;
|
||||
|
||||
our $adb = esmith::AccountsDB->open_ro or die "Couldn't open AccountsDB";
|
||||
our $cdb = esmith::ConfigDB->open_ro or die "Couldn't open ConfigDB";
|
||||
|
||||
$user = $adb->get($USERNAME) or die "No user $USERNAME in AccountsDB";
|
||||
%props = $user->props;
|
||||
|
||||
our $zarafa1 = $props{zarafa} || 'disabled1';
|
||||
our $zarafa2 = ${'zarafa-server'}{GlobalForward} || 'disabled2';
|
||||
|
||||
# If Sieve is enabled for user, mails should be delivered through dovecot-lda
|
||||
# rather than going directly to users Maildir.
|
||||
|
||||
our $sievesupport = $cdb->get_prop('sieve','status') || 'disabled';
|
||||
our $sieveuser = $props{Sieve} || 'enabled';
|
||||
|
||||
if (($sieveuser eq 'enabled') && ($sievesupport eq 'enabled'))
|
||||
{
|
||||
our $finaldeliverymethod = 'to "| /usr/libexec/dovecot/deliver"';
|
||||
}
|
||||
else
|
||||
{
|
||||
our $finaldeliverymethod = 'to Maildir';
|
||||
}
|
||||
|
||||
our $EmailForward = $props{EmailForward} || '';
|
||||
our $ForwardAddress = $props{ForwardAddress} || '';
|
||||
|
||||
$OUT = '';
|
||||
}
|
9
root/etc/e-smith/templates-user/.mailfilter/10header
Normal file
9
root/etc/e-smith/templates-user/.mailfilter/10header
Normal file
@@ -0,0 +1,9 @@
|
||||
# ---------------------------------------
|
||||
# ~/.mailfilter
|
||||
# ---------------------------------------
|
||||
|
||||
DEFAULT=$HOME/Maildir/
|
||||
SENDMAIL="/var/qmail/bin/sendmail"
|
||||
reformail="/usr/bin/reformail"
|
||||
SHELL="/bin/bash"
|
||||
|
1
root/etc/e-smith/templates-user/.mailfilter/15log
Normal file
1
root/etc/e-smith/templates-user/.mailfilter/15log
Normal file
@@ -0,0 +1 @@
|
||||
logfile "mailfilter.log"
|
45
root/etc/e-smith/templates-user/.mailfilter/25options
Normal file
45
root/etc/e-smith/templates-user/.mailfilter/25options
Normal file
@@ -0,0 +1,45 @@
|
||||
{
|
||||
use esmith::config;
|
||||
use esmith::db;
|
||||
|
||||
my %accounts;
|
||||
tie %accounts, 'esmith::config', '/home/e-smith/db/accounts';
|
||||
|
||||
# get $USERNAME from esmith::config
|
||||
die "Username criterion missing." unless defined ($USERNAME);
|
||||
|
||||
my $type = db_get_type(\%accounts, $USERNAME);
|
||||
|
||||
die
|
||||
"Account $USERNAME is not a user account; "
|
||||
. "update email forwarding failed.\n"
|
||||
unless $type eq 'user' || $USERNAME eq 'admin';
|
||||
|
||||
my %processmail;
|
||||
tie %processmail, 'esmith::config', '/home/e-smith/db/processmail';
|
||||
|
||||
# keep backups
|
||||
my $backup = db_get_prop(\%processmail, $USERNAME, "backup") || '';
|
||||
if ($backup eq 'yes')
|
||||
{
|
||||
$OUT .= "\n";
|
||||
$OUT .= "# ---- keep backups ----\n";
|
||||
$OUT .= "cc backup\n";
|
||||
$OUT .= "`cd backup/new && rm -f dummy \`ls -t | sed -e 1,50d\``\n";
|
||||
}
|
||||
|
||||
## delete duplicates
|
||||
my $deldups = db_get_prop(\%processmail, $USERNAME, "deldups") || 'no';
|
||||
my $globaldeldups = db_get_prop(\%processmail, 'maildrop', "deldups") || 'no';
|
||||
if (($deldups eq 'yes') ||($globaldeldups eq 'yes'))
|
||||
{
|
||||
$OUT .= "\n";
|
||||
$OUT .= "# ----- delete duplicates ---\n";
|
||||
$OUT .= "`reformail -D 8000 duplicate.cache`\n";
|
||||
$OUT .= "if ( \$RETURNCODE == 0 )\n";
|
||||
$OUT .= "\{\n";
|
||||
$OUT .= "log \"--------- duplicate deleted -- \"\n";
|
||||
$OUT .= "exit\n";
|
||||
$OUT .= "\}\n";
|
||||
}
|
||||
}
|
44
root/etc/e-smith/templates-user/.mailfilter/35WordFilter
Normal file
44
root/etc/e-smith/templates-user/.mailfilter/35WordFilter
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
use esmith::config;
|
||||
use esmith::db;
|
||||
|
||||
my %processmail;
|
||||
tie %processmail, 'esmith::config', '/home/e-smith/db/processmail';
|
||||
|
||||
# word filter, unix text file with bad words to match
|
||||
if ( -e "/opt/wordfilter")
|
||||
{
|
||||
my $WordFilter = db_get_prop(\%processmail, 'maildrop', "WordFilter") || 'no';
|
||||
|
||||
if ($WordFilter =~ /(junkmail|delete)/)
|
||||
{
|
||||
my $target;
|
||||
my $targetlog;
|
||||
|
||||
if ($WordFilter eq 'junkmail')
|
||||
{
|
||||
$targetlog = 'to junkmail';
|
||||
$target = 'to Maildir/.junkmail';
|
||||
}
|
||||
elsif ($WordFilter eq 'delete')
|
||||
{
|
||||
$targetlog = 'delete';
|
||||
$target = 'exit';
|
||||
}
|
||||
# bypass large email so we don't slow down server
|
||||
# assume most offending emails are small
|
||||
|
||||
$OUT .= "\n";
|
||||
$OUT .= "# ----- word filter ---\n";
|
||||
$OUT .= "if (\$SIZE < 5000 )\n";
|
||||
$OUT .= "\{\n";
|
||||
$OUT .= " if ( /.*/:b && lookup( \$MATCH, \"/opt/wordfilter\" ))\n";
|
||||
$OUT .= " \{\n";
|
||||
$OUT .= " log \"--------- word filter -- \"\n";
|
||||
$OUT .= " log \"--- ----- $targetlog -- \"\n";
|
||||
$OUT .= " $target \n";
|
||||
$OUT .= " \}\n";
|
||||
$OUT .= "\}\n";
|
||||
}
|
||||
}
|
||||
}
|
164
root/etc/e-smith/templates-user/.mailfilter/40global
Normal file
164
root/etc/e-smith/templates-user/.mailfilter/40global
Normal file
@@ -0,0 +1,164 @@
|
||||
{
|
||||
use esmith::config;
|
||||
use esmith::db;
|
||||
|
||||
my %conf;
|
||||
tie %conf, 'esmith::config';
|
||||
|
||||
my %accounts;
|
||||
tie %accounts, 'esmith::config', '/home/e-smith/db/accounts';
|
||||
|
||||
die "Username missing." unless defined ($USERNAME);
|
||||
|
||||
my $type = db_get_type(\%accounts, $USERNAME);
|
||||
|
||||
die
|
||||
"Account $USERNAME is not a user account; "
|
||||
. "update email forwarding failed.\n"
|
||||
unless $type eq 'user' || $USERNAME eq 'admin';
|
||||
|
||||
my %processmail;
|
||||
tie %processmail, 'esmith::config', '/home/e-smith/db/processmail';
|
||||
|
||||
# the syntax of imap folder names keeps changing
|
||||
my $sep = '.';
|
||||
|
||||
#get Global rules
|
||||
my @pmGlobRules = ();
|
||||
foreach (sort keys %processmail)
|
||||
{
|
||||
push (@pmGlobRules, $_)
|
||||
if (db_get_type(\%processmail, $_) eq 'pmGlobalRule');
|
||||
}
|
||||
|
||||
#if they have rules add them to the templete
|
||||
my $pmGlobRules = @pmGlobRules || '0';
|
||||
if ($pmGlobRules > 0)
|
||||
{
|
||||
$OUT .= "\n";
|
||||
$OUT .= "# ----start of Global rules--------\n";
|
||||
|
||||
my $pmGlobRule;
|
||||
foreach $pmGlobRule (sort {$a <=> $b} @pmGlobRules)
|
||||
{
|
||||
my $basis = db_get_prop(\%processmail, $pmGlobRule, "basis") || '';
|
||||
my $criterion = db_get_prop(\%processmail, $pmGlobRule, "criterion") || '';
|
||||
my $basis2 = db_get_prop(\%processmail, $pmGlobRule, "basis2") || '';
|
||||
my $secondtest = db_get_prop(\%processmail, $pmGlobRule, "basis2") || '';
|
||||
my $criterion2 = db_get_prop(\%processmail, $pmGlobRule, "criterion2") || '';
|
||||
my $deliver = db_get_prop(\%processmail, $pmGlobRule, "deliver") || '';
|
||||
my $deliver2 = db_get_prop(\%processmail, $pmGlobRule, "deliver2") || '';
|
||||
my $copy = db_get_prop(\%processmail, $pmGlobRule, "copy") || '';
|
||||
my $action = db_get_prop(\%processmail, $pmGlobRule, "action") || '';
|
||||
my $action2 = db_get_prop(\%processmail, $pmGlobRule, "action2") || '';
|
||||
|
||||
## headers include the basis in the criterion
|
||||
if ($basis eq 'headers')
|
||||
{
|
||||
$basis = $criterion;
|
||||
$criterion = '';
|
||||
}
|
||||
|
||||
if ($basis2 eq 'headers')
|
||||
{
|
||||
$basis2 = $criterion2;
|
||||
$criterion2 = '';
|
||||
}
|
||||
|
||||
## convert to procmail 'TO_' macro equivalent ??
|
||||
foreach ($basis, $basis2)
|
||||
{
|
||||
if ($_ eq 'TO_')
|
||||
{
|
||||
#$_ = '((Original-)?(Resent-)?(To|Cc|Bcc)|(X-Envelope|Apparently(-Resent)?)-To)';
|
||||
$_ = '(To|Cc)';
|
||||
}
|
||||
}
|
||||
|
||||
## construct the deliver line
|
||||
if ($action eq 'sort')
|
||||
{
|
||||
# to a folder
|
||||
$deliver1 = "to \"Maildir/"."$sep"."$deliver"."/\"";
|
||||
}
|
||||
elsif ($action eq 'forward')
|
||||
{
|
||||
# to an email
|
||||
$deliver1 = "to "."\"!$deliver\"";
|
||||
}
|
||||
elsif ($action eq 'delete')
|
||||
{
|
||||
# delete it, report, and add a blank line
|
||||
$deliver1 = "log \" --deleted --\" \n log \"\" \n exit";
|
||||
#$deliver1 = "log \"--- deleted --\" \n log \"From: $From \" \n log \"Subject: $Subject \" \n log \"\" \n exit";
|
||||
}
|
||||
else
|
||||
{
|
||||
# freeform
|
||||
$deliver1 = "$deliver";
|
||||
}
|
||||
|
||||
## construct the 2nd deliver line
|
||||
if ($action2 eq 'sort')
|
||||
{
|
||||
# to a folder
|
||||
$deliver2 = "\"Maildir/"."$sep"."$deliver2"."/\"";
|
||||
}
|
||||
elsif ($action2 eq 'forward')
|
||||
{
|
||||
# to an email
|
||||
$deliver2 = "\"!$deliver2\"";
|
||||
}
|
||||
|
||||
$OUT .= "\n";
|
||||
if ($secondtest eq '')
|
||||
{
|
||||
if ($basis =~ /(>|<)/)
|
||||
{
|
||||
$OUT .= "if ( \$SIZE $basis $criterion )\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$OUT .= "if ( /^"."$basis".".*$criterion/ )\n";
|
||||
}
|
||||
$OUT .= "\{\n";
|
||||
$OUT .= "log \"--------- match user rule -- \"\n";
|
||||
$OUT .= "log \"--------- $basis $criterion -- \"\n";
|
||||
|
||||
}
|
||||
#basis2 can't test on size
|
||||
else
|
||||
{
|
||||
if ($basis =~ /(>|<)/)
|
||||
{
|
||||
$OUT .= "if (( \$SIZE $basis $criterion ) && ( /^"."$basis2".".*$criterion2/ ))\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$OUT .= "if (( /^"."$basis".".*$criterion/) && (/^"."$basis2".".*$criterion2/ ))\n";
|
||||
}
|
||||
$OUT .= "\{\n";
|
||||
$OUT .= "log \"--- match user rule ------------- \"\n";
|
||||
$OUT .= "log \"--- $basis $criterion & $basis2 $criterion2 -- \"\n";
|
||||
}
|
||||
|
||||
if ($copy eq 'no')
|
||||
{
|
||||
$OUT .= "$deliver1\n";
|
||||
$OUT .= "\}\n";
|
||||
}
|
||||
elsif ($copy eq 'yes' && $action2 eq 'inbox')
|
||||
{
|
||||
$OUT .= "cc Maildir\n";
|
||||
$OUT .= "$deliver1\n";
|
||||
$OUT .= "\}\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$OUT .= "cc $deliver2\n";
|
||||
$OUT .= "$deliver1\n";
|
||||
$OUT .= "\}\n";
|
||||
}
|
||||
}#foreach rule
|
||||
}#if rules exist
|
||||
}
|
164
root/etc/e-smith/templates-user/.mailfilter/60user
Normal file
164
root/etc/e-smith/templates-user/.mailfilter/60user
Normal file
@@ -0,0 +1,164 @@
|
||||
{
|
||||
use esmith::config;
|
||||
use esmith::db;
|
||||
|
||||
my %conf;
|
||||
tie %conf, 'esmith::config';
|
||||
|
||||
my %accounts;
|
||||
tie %accounts, 'esmith::config', '/home/e-smith/db/accounts';
|
||||
|
||||
die "Username criterion missing." unless defined ($USERNAME);
|
||||
|
||||
my $type = db_get_type(\%accounts, $USERNAME);
|
||||
|
||||
die
|
||||
"Account $USERNAME is not a user account; "
|
||||
. "update email forwarding failed.\n"
|
||||
unless $type eq 'user' || $USERNAME eq 'admin';
|
||||
|
||||
my %processmail;
|
||||
tie %processmail, 'esmith::config', '/home/e-smith/db/processmail';
|
||||
|
||||
# the syntax of imap folder names keeps changing
|
||||
my $sep = '.';
|
||||
|
||||
# get users rules
|
||||
my @pmRules = ();
|
||||
foreach (sort keys %processmail)
|
||||
{
|
||||
push (@pmRules, $_)
|
||||
if (db_get_type(\%processmail, $_) eq $USERNAME);
|
||||
}
|
||||
|
||||
# if they have rules add them to the templete
|
||||
my $pmRules = @pmRules || '0';
|
||||
if ($pmRules > 0)
|
||||
{
|
||||
$OUT .= "\n";
|
||||
$OUT .= "# ----- user rules ----\n";
|
||||
|
||||
my $pmRule;
|
||||
foreach $pmRule (sort @pmRules)
|
||||
{
|
||||
my $basis = db_get_prop(\%processmail, $pmRule, "basis") || '';
|
||||
my $criterion = db_get_prop(\%processmail, $pmRule, "criterion") || '';
|
||||
my $basis2 = db_get_prop(\%processmail, $pmRule, "basis2") || '';
|
||||
my $secondtest = db_get_prop(\%processmail, $pmRule, "basis2") || '';
|
||||
my $criterion2 = db_get_prop(\%processmail, $pmRule, "criterion2") || '';
|
||||
my $deliver = db_get_prop(\%processmail, $pmRule, "deliver") || '';
|
||||
my $deliver1 = '';
|
||||
my $deliver2 = db_get_prop(\%processmail, $pmRule, "deliver2") || '';
|
||||
my $copy = db_get_prop(\%processmail, $pmRule, "copy") || '';
|
||||
my $action = db_get_prop(\%processmail, $pmRule, "action") || '';
|
||||
my $action2 = db_get_prop(\%processmail, $pmRule, "action2") || '';
|
||||
|
||||
## headers include the basis in the criterion
|
||||
if ($basis eq 'headers')
|
||||
{
|
||||
$basis = $criterion;
|
||||
$criterion = '';
|
||||
}
|
||||
|
||||
if ($basis2 eq 'headers')
|
||||
{
|
||||
$basis2 = $criterion2;
|
||||
$criterion2 = '';
|
||||
}
|
||||
|
||||
## convert to procmail 'TO_' macro equivalent ??
|
||||
foreach ($basis, $basis2)
|
||||
{
|
||||
if ($_ eq 'TO_')
|
||||
{
|
||||
#$_ = '((Original-)?(Resent-)?(To|Cc|Bcc)|(X-Envelope|Apparently(-Resent)?)-To)';
|
||||
$_ = '(To|Cc)';
|
||||
}
|
||||
}
|
||||
|
||||
## construct the deliver line
|
||||
if ($action eq 'sort')
|
||||
{
|
||||
# to a folder
|
||||
$deliver1 = "to \"Maildir/"."$sep"."$deliver"."/\"";
|
||||
}
|
||||
elsif ($action eq 'forward')
|
||||
{
|
||||
# to an email
|
||||
$deliver1 = "to "."\"!$deliver\"";
|
||||
}
|
||||
elsif ($action eq 'delete')
|
||||
{
|
||||
# delete it, report, and add a blank line
|
||||
$deliver1 = "log \"--- $basis $criterion --deleted --\" \n log \"\" \n exit";
|
||||
}
|
||||
else
|
||||
{
|
||||
# freeform
|
||||
$deliver1 = "$deliver";
|
||||
}
|
||||
|
||||
## construct the 2nd deliver line
|
||||
if ($action2 eq 'sort')
|
||||
{
|
||||
# to a folder
|
||||
$deliver2 = "\"Maildir/"."$sep"."$deliver2"."/\"";
|
||||
}
|
||||
elsif ($action2 eq 'forward')
|
||||
{
|
||||
# to an email
|
||||
$deliver2 = "\"!$deliver2\"";
|
||||
}
|
||||
|
||||
$OUT .= "\n";
|
||||
if ($secondtest eq '')
|
||||
{
|
||||
if ($basis =~ /(>|<)/)
|
||||
{
|
||||
$OUT .= "if ( \$SIZE $basis $criterion )\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$OUT .= "if ( /^"."$basis".".*$criterion/ )\n";
|
||||
}
|
||||
$OUT .= "\{\n";
|
||||
$OUT .= "log \"--------- match user rule -- \"\n";
|
||||
$OUT .= "log \"--------- $basis $criterion -- \"\n";
|
||||
|
||||
}
|
||||
#basis2 can't test on size
|
||||
else
|
||||
{
|
||||
if ($basis =~ /(>|<)/)
|
||||
{
|
||||
$OUT .= "if (( \$SIZE $basis $criterion ) && ( /^"."$basis2".".*$criterion2/ ))\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$OUT .= "if (( /^"."$basis".".*$criterion/) && (/^"."$basis2".".*$criterion2/ ))\n";
|
||||
}
|
||||
$OUT .= "\{\n";
|
||||
$OUT .= "log \"--- match user rule ------------- \"\n";
|
||||
$OUT .= "log \"--- $basis $criterion & $basis2 $criterion2 -- \"\n";
|
||||
}
|
||||
|
||||
if ($copy eq 'no')
|
||||
{
|
||||
$OUT .= "$deliver1\n";
|
||||
$OUT .= "\}\n";
|
||||
}
|
||||
elsif ($copy eq 'yes' && $action2 eq 'inbox')
|
||||
{
|
||||
$OUT .= "cc Maildir\n";
|
||||
$OUT .= "$deliver1\n";
|
||||
$OUT .= "\}\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$OUT .= "cc $deliver2\n";
|
||||
$OUT .= "$deliver1\n";
|
||||
$OUT .= "\}\n";
|
||||
}
|
||||
}#foreach rule
|
||||
}#if rules exist
|
||||
}
|
36
root/etc/e-smith/templates-user/.mailfilter/90default
Normal file
36
root/etc/e-smith/templates-user/.mailfilter/90default
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
if ($qmail{FilterOrder})
|
||||
{
|
||||
|
||||
# honour EmailForward
|
||||
my $EmailForward = $props{EmailForward} || '';
|
||||
my $ForwardAddress = $props{ForwardAddress} || '';
|
||||
|
||||
if ($EmailForward eq 'forward')
|
||||
{
|
||||
$OUT .= "\n";
|
||||
$OUT .= "log \"--- forward mail ---------------- \"\n";
|
||||
$OUT .= "to \"!$ForwardAddress\"";
|
||||
}
|
||||
elsif ($EmailForward eq 'both')
|
||||
{
|
||||
$OUT .= "\n";
|
||||
$OUT .= "log \"--- to the inbox and forward ----- \"\n";
|
||||
$OUT .= "cc Maildir\n";
|
||||
$OUT .= "to \"!$ForwardAddress\"";
|
||||
}
|
||||
else
|
||||
{
|
||||
$OUT .= "\n";
|
||||
$OUT .= "log \"--- to the inbox ----------------- \"\n";
|
||||
$OUT .= "$finaldeliverymethod";
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$OUT .= "\n";
|
||||
$OUT .= "log \"--- to the inbox ----------------- \"\n";
|
||||
$OUT .= "$finaldeliverymethod\n";
|
||||
}
|
||||
}
|
21
root/etc/e-smith/templates-user/.procmailrc/00setup
Normal file
21
root/etc/e-smith/templates-user/.procmailrc/00setup
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
# vim: ft=perl:
|
||||
|
||||
use esmith::AccountsDB;
|
||||
use esmith::ConfigDB;
|
||||
|
||||
our $adb = esmith::AccountsDB->open_ro or die "Couldn't open AccountsDB";
|
||||
our $cdb = esmith::ConfigDB->open_ro or die "Couldn't open ConfigDB";
|
||||
|
||||
$user = $adb->get($USERNAME) or die "No user $USERNAME in AccountsDB";
|
||||
%props = $user->props;
|
||||
|
||||
our $sievesupport = $cdb->get_prop('sieve','status') || 'disabled';
|
||||
our $sieveuser = $props{Sieve} || 'enabled';
|
||||
our $zarafa1 = $props{zarafa} || 'disabled1';
|
||||
our $zarafa2 = ${'zarafa-server'}{GlobalForward} || 'disabled2';
|
||||
our $EmailForward = $props{EmailForward} || '';
|
||||
our $ForwardAddress = $props{ForwardAddress} || '';
|
||||
|
||||
$OUT = '';
|
||||
}
|
24
root/etc/e-smith/templates-user/.procmailrc/10header
Normal file
24
root/etc/e-smith/templates-user/.procmailrc/10header
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
if ($USERNAME ne 'admin')
|
||||
{
|
||||
$OUT .= "# ---- Defaults ------------------\n";
|
||||
$OUT .= "SHELL=/bin/bash\n";
|
||||
$OUT .= "DEFAULT=\$HOME/Maildir/\n";
|
||||
$OUT .= "FORMAIL=/usr/bin/formail\n";
|
||||
$OUT .= "MAILDIR=\$HOME/Maildir/\n";
|
||||
$OUT .= "PMDIR=\$HOME\n";
|
||||
$OUT .= "SENDMAIL=/usr/sbin/sendmail\n";
|
||||
}
|
||||
|
||||
elsif ($USERNAME eq 'admin')
|
||||
{
|
||||
$OUT .= "# ---- Defaults ------------------\n";
|
||||
$OUT .= "SHELL=/bin/bash\n";
|
||||
$OUT .= "DEFAULT=/home/e-smith/Maildir/\n";
|
||||
$OUT .= "FORMAIL=/usr/bin/formail\n";
|
||||
$OUT .= "MAILDIR=/home/e-smith/Maildir/\n";
|
||||
$OUT .= "PMDIR=/home/e-smith\n";
|
||||
$OUT .= "SENDMAIL=/usr/sbin/sendmail\n";
|
||||
}
|
||||
}
|
||||
|
47
root/etc/e-smith/templates-user/.procmailrc/15log
Normal file
47
root/etc/e-smith/templates-user/.procmailrc/15log
Normal file
@@ -0,0 +1,47 @@
|
||||
{
|
||||
use esmith::config;
|
||||
use esmith::db;
|
||||
|
||||
my %processmail;
|
||||
tie %processmail, 'esmith::config', '/home/e-smith/db/processmail';
|
||||
|
||||
$OUT = '';
|
||||
|
||||
# control level of logging
|
||||
my $loglevel = db_get_prop(\%processmail, $USERNAME, "loglevel") || 'some';
|
||||
if ($loglevel eq 'none')
|
||||
{
|
||||
$OUT .= "\n";
|
||||
$OUT .= "# ---- no logging ------------------\n";
|
||||
}
|
||||
elsif ($loglevel eq 'some')
|
||||
{
|
||||
$OUT .= "\n";
|
||||
$OUT .= "# ---- some logging------------------\n";
|
||||
$OUT .= "VERBOSE=no\n";
|
||||
if ($USERNAME ne "admin")
|
||||
{
|
||||
$OUT .= "LOGFILE=\$HOME/procmail.log\n";
|
||||
}
|
||||
if ($USERNAME eq "admin")
|
||||
{
|
||||
$OUT .= "LOGFILE=/home/e-smith/procmail.log\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$OUT .= "\n";
|
||||
$OUT .= "# ---- verbose, for debugging only --------------\n";
|
||||
$OUT .= "VERBOSE=yes\n";
|
||||
$OUT .= "LOGABSTRACT=all\n";
|
||||
if ($USERNAME ne "admin")
|
||||
{
|
||||
$OUT .= "LOGFILE=\$HOME/procmail.log\n";
|
||||
}
|
||||
if ($USERNAME eq "admin")
|
||||
{
|
||||
$OUT .= "LOGFILE=/home/e-smith/procmail.log\n";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
6
root/etc/e-smith/templates-user/.procmailrc/25options
Normal file
6
root/etc/e-smith/templates-user/.procmailrc/25options
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
$OUT .= "\n";
|
||||
$OUT .= "# ---- delete duplicates -------\n";
|
||||
$OUT .= ":0 Wh: msgid.lock\n";
|
||||
$OUT .= "| \$FORMAIL -D 8192 msgid.cache\n";
|
||||
}
|
166
root/etc/e-smith/templates-user/.procmailrc/40global
Normal file
166
root/etc/e-smith/templates-user/.procmailrc/40global
Normal file
@@ -0,0 +1,166 @@
|
||||
{
|
||||
use esmith::config;
|
||||
use esmith::db;
|
||||
|
||||
my %processmail;
|
||||
tie %processmail, 'esmith::config', '/home/e-smith/db/processmail';
|
||||
|
||||
#get Global rules
|
||||
my @pmGlobRules = ();
|
||||
foreach (sort keys %processmail)
|
||||
{
|
||||
push (@pmGlobRules, $_)
|
||||
if (db_get_type(\%processmail, $_) eq 'pmGlobalRule');
|
||||
}
|
||||
|
||||
#if they have rules add them to the templete
|
||||
my $pmGlobRules = @pmGlobRules || '0';
|
||||
if ($pmGlobRules > 0)
|
||||
{
|
||||
$OUT .= "\n";
|
||||
$OUT .= "# ---start of Global rules---------\n";
|
||||
|
||||
my $pmGlobRule;
|
||||
foreach $pmGlobRule (sort {$a <=> $b} @pmGlobRules)
|
||||
{
|
||||
my $basis = db_get_prop(\%processmail, $pmGlobRule, "basis") || '';
|
||||
my $criterion = db_get_prop(\%processmail, $pmGlobRule, "criterion") || '';
|
||||
my $basis2 = db_get_prop(\%processmail, $pmGlobRule, "basis2") || '';
|
||||
my $secondtest = db_get_prop(\%processmail, $pmGlobRule, "basis2") || '';
|
||||
my $criterion2 = db_get_prop(\%processmail, $pmGlobRule, "criterion2") || '';
|
||||
my $deliver = db_get_prop(\%processmail, $pmGlobRule, "deliver") || '';
|
||||
my $deliver2 = db_get_prop(\%processmail, $pmGlobRule, "deliver2") || '';
|
||||
my $copy = db_get_prop(\%processmail, $pmGlobRule, "copy") || '';
|
||||
my $action = db_get_prop(\%processmail, $pmGlobRule, "action") || '';
|
||||
my $action2 = db_get_prop(\%processmail, $pmGlobRule, "action2") || '';
|
||||
|
||||
unless (($zarafa1 eq 'enabled') || ($zarafa2 eq 'enabled'))
|
||||
{
|
||||
$deliver =~ s/ /\\ /g;
|
||||
$deliver2 =~ s/ /\\ /g;
|
||||
}
|
||||
|
||||
foreach ($basis, $basis2)
|
||||
{
|
||||
## headers include the basis in the criterion
|
||||
if ($_ eq 'headers')
|
||||
{
|
||||
$_ = '';
|
||||
}
|
||||
|
||||
## size doesn't use '^. *' but needs a space
|
||||
if ($_ ne '<')
|
||||
{
|
||||
if ($_ ne '>')
|
||||
{
|
||||
#[sme 2264] remove .* after TO_ macro
|
||||
if ($_ eq 'TO_')
|
||||
{
|
||||
#[sme 6061 remove space after TO_
|
||||
$_ = "^"."$_"."";
|
||||
}
|
||||
else
|
||||
{
|
||||
$_ = "^"."$_".".*";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$_ = $_.' ';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$_ = $_.' ';
|
||||
}
|
||||
}
|
||||
|
||||
##construct the deliver line
|
||||
if (($action eq 'sort') || ($action eq 'create'))
|
||||
{
|
||||
# to a folder
|
||||
if (($zarafa1 eq 'enabled') || ($zarafa2 eq 'enabled'))
|
||||
{
|
||||
if ($deliver eq 'junkmail')
|
||||
{ $deliver = "| zarafa-dagent -j $USERNAME"; }
|
||||
else
|
||||
{ $deliver = "| zarafa-dagent $USERNAME -C -F 'Inbox\\$deliver'"; }
|
||||
}
|
||||
else
|
||||
{ $deliver = "\$MAILDIR/".'.'."$deliver"."/"; }
|
||||
}
|
||||
elsif ($action eq 'forward')
|
||||
{
|
||||
# to an email
|
||||
$deliver = "! "."$deliver";
|
||||
}
|
||||
elsif ($action eq 'delete')
|
||||
{
|
||||
# delete it
|
||||
$deliver = '/dev/null';
|
||||
}
|
||||
else
|
||||
{
|
||||
# freeform
|
||||
$deliver = "$deliver";
|
||||
}
|
||||
|
||||
##construct the 2nd deliver line
|
||||
if ($action2 eq 'sort')
|
||||
{
|
||||
# to a folder
|
||||
if (($zarafa1 eq 'enabled') || ($zarafa2 eq 'enabled'))
|
||||
{
|
||||
if ($deliver eq 'junkmail')
|
||||
{ $deliver = "| zarafa-dagent -j $USERNAME"; }
|
||||
else
|
||||
{ $deliver = "| zarafa-dagent $USERNAME -C -F 'Inbox\\$deliver'"; }
|
||||
}
|
||||
else
|
||||
{ $deliver = "\$MAILDIR/".'.'."$deliver2"."/"; }
|
||||
}
|
||||
elsif ($action2 eq 'forward')
|
||||
{
|
||||
# to an email
|
||||
$deliver2 = "! "."$deliver2";
|
||||
}
|
||||
|
||||
## construct the rule
|
||||
if ($secondtest ne '')
|
||||
{
|
||||
$secondtest = "* "."$basis2"."$criterion2"."\n";
|
||||
}
|
||||
|
||||
if ($copy eq 'no')
|
||||
{
|
||||
$OUT .= "\n";
|
||||
$OUT .= ":0\n";
|
||||
$OUT .= "* "."$basis"."$criterion"."\n";
|
||||
$OUT .= $secondtest;
|
||||
$OUT .= "$deliver\n";
|
||||
}
|
||||
elsif ($copy eq 'yes' && $action2 eq 'inbox')
|
||||
{
|
||||
$OUT .= "\n";
|
||||
$OUT .= ":0 c\n";
|
||||
$OUT .= "* "."$basis"."$criterion"."\n";
|
||||
$OUT .= $secondtest;
|
||||
$OUT .= "$deliver\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$OUT .= "\n";
|
||||
$OUT .= ":0\n";
|
||||
$OUT .= "* "."$basis"."$criterion"."\n";
|
||||
$OUT .= $secondtest;
|
||||
$OUT .= "\{\n";
|
||||
$OUT .= " :0 c\n";
|
||||
$OUT .= " $deliver\n";
|
||||
$OUT .= " \n";
|
||||
$OUT .= " :0\n";
|
||||
$OUT .= " $deliver2\n";
|
||||
$OUT .= "\}\n";
|
||||
}
|
||||
}#foreach rule
|
||||
}#if rules exist
|
||||
}
|
167
root/etc/e-smith/templates-user/.procmailrc/60user
Normal file
167
root/etc/e-smith/templates-user/.procmailrc/60user
Normal file
@@ -0,0 +1,167 @@
|
||||
{
|
||||
use esmith::config;
|
||||
use esmith::db;
|
||||
|
||||
my %processmail;
|
||||
tie %processmail, 'esmith::config', '/home/e-smith/db/processmail';
|
||||
|
||||
# get users rules
|
||||
my @pmRules = ();
|
||||
foreach (sort keys %processmail)
|
||||
{
|
||||
push (@pmRules, $_)
|
||||
if (db_get_type(\%processmail, $_) eq $USERNAME);
|
||||
}
|
||||
|
||||
# if they have rules add them to the templete
|
||||
my $pmRules = @pmRules || '0';
|
||||
if ($pmRules > 0)
|
||||
{
|
||||
$OUT .= "\n";
|
||||
$OUT .= "# ---- user rules ------------------\n";
|
||||
|
||||
my $pmRule;
|
||||
foreach $pmRule (sort @pmRules)
|
||||
{
|
||||
my $basis = db_get_prop(\%processmail, $pmRule, "basis") || '';
|
||||
my $criterion = db_get_prop(\%processmail, $pmRule, "criterion") || '';
|
||||
my $basis2 = db_get_prop(\%processmail, $pmRule, "basis2") || '';
|
||||
my $secondtest = db_get_prop(\%processmail, $pmRule, "basis2") || '';
|
||||
my $criterion2 = db_get_prop(\%processmail, $pmRule, "criterion2") || '';
|
||||
my $deliver = db_get_prop(\%processmail, $pmRule, "deliver") || '';
|
||||
my $deliver2 = db_get_prop(\%processmail, $pmRule, "deliver2") || '';
|
||||
my $copy = db_get_prop(\%processmail, $pmRule, "copy") || '';
|
||||
my $action = db_get_prop(\%processmail, $pmRule, "action") || '';
|
||||
my $action2 = db_get_prop(\%processmail, $pmRule, "action2") || '';
|
||||
|
||||
#allow for spaces _ to \_
|
||||
unless (($zarafa1 eq 'enabled') || ($zarafa2 eq 'enabled'))
|
||||
{
|
||||
$deliver =~ s/ /\\ /g;
|
||||
$deliver2 =~ s/ /\\ /g;
|
||||
}
|
||||
|
||||
foreach ($basis, $basis2)
|
||||
{
|
||||
## headers include the basis in the criterion
|
||||
if ($_ eq 'headers')
|
||||
{
|
||||
$_ = '';
|
||||
}
|
||||
|
||||
## size doesn't use '^. *' but needs a space
|
||||
if ($_ ne '<')
|
||||
{
|
||||
if ($_ ne '>')
|
||||
{
|
||||
#[sme 2264] remove .* after TO_ macro
|
||||
if ($_ eq 'TO_')
|
||||
{
|
||||
#[sme 6061 remove space after TO_
|
||||
$_ = "^"."$_"."";
|
||||
}
|
||||
else
|
||||
{
|
||||
$_ = "^"."$_".".*";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$_ = $_.' ';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$_ = $_.' ';
|
||||
}
|
||||
}
|
||||
|
||||
##construct the deliver line
|
||||
if (($action eq 'sort') || ($action eq 'create'))
|
||||
{
|
||||
# to a folder
|
||||
if (($zarafa1 eq 'enabled') || ($zarafa2 eq 'enabled'))
|
||||
{
|
||||
if ($deliver eq 'junkmail')
|
||||
{ $deliver = "| zarafa-dagent -j $USERNAME"; }
|
||||
else
|
||||
{ $deliver = "| zarafa-dagent $USERNAME -C -F 'Inbox\\$deliver'"; }
|
||||
}
|
||||
else
|
||||
{ $deliver = "\$MAILDIR/".'.'."$deliver"."/"; }
|
||||
}
|
||||
elsif ($action eq 'forward')
|
||||
{
|
||||
# to an email
|
||||
$deliver = "! "."$deliver";
|
||||
}
|
||||
elsif ($action eq 'delete')
|
||||
{
|
||||
# delete it
|
||||
$deliver = '/dev/null';
|
||||
}
|
||||
else
|
||||
{
|
||||
# freeform
|
||||
$deliver = "$deliver";
|
||||
}
|
||||
|
||||
##construct the 2nd deliver line
|
||||
if ($action2 eq 'sort')
|
||||
{
|
||||
# to a folder
|
||||
if (($zarafa1 eq 'enabled') || ($zarafa2 eq 'enabled'))
|
||||
{
|
||||
if ($deliver eq 'junkmail')
|
||||
{ $deliver = "| zarafa-dagent -j $USERNAME"; }
|
||||
else
|
||||
{ $deliver = "| zarafa-dagent $USERNAME -C -F 'Inbox\\$deliver'"; }
|
||||
}
|
||||
else
|
||||
{ $deliver = "\$MAILDIR/".'.'."$deliver2"."/"; }
|
||||
}
|
||||
elsif ($action2 eq 'forward')
|
||||
{
|
||||
# to an email
|
||||
$deliver2 = "! "."$deliver2";
|
||||
}
|
||||
|
||||
## construct the rule
|
||||
if ($secondtest ne '')
|
||||
{
|
||||
$secondtest = "* "."$basis2"."$criterion2"."\n";
|
||||
}
|
||||
|
||||
if ($copy eq 'no')
|
||||
{
|
||||
$OUT .= "\n";
|
||||
$OUT .= ":0\n";
|
||||
$OUT .= "* "."$basis"."$criterion"."\n";
|
||||
$OUT .= $secondtest;
|
||||
$OUT .= "$deliver\n";
|
||||
}
|
||||
elsif ($copy eq 'yes' && $action2 eq 'inbox')
|
||||
{
|
||||
$OUT .= "\n";
|
||||
$OUT .= ":0 c\n";
|
||||
$OUT .= "* "."$basis"."$criterion"."\n";
|
||||
$OUT .= $secondtest;
|
||||
$OUT .= "$deliver\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$OUT .= "\n";
|
||||
$OUT .= ":0\n";
|
||||
$OUT .= "* "."$basis"."$criterion"."\n";
|
||||
$OUT .= $secondtest;
|
||||
$OUT .= "\{\n";
|
||||
$OUT .= " :0 c\n";
|
||||
$OUT .= " $deliver\n";
|
||||
$OUT .= " \n";
|
||||
$OUT .= " :0\n";
|
||||
$OUT .= " $deliver2\n";
|
||||
$OUT .= "\}\n";
|
||||
}
|
||||
}#foreach rule
|
||||
}#if rules exist
|
||||
}
|
23
root/etc/e-smith/templates-user/.procmailrc/90default
Normal file
23
root/etc/e-smith/templates-user/.procmailrc/90default
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
$OUT .= "\n";
|
||||
$OUT .= "# ---- to the inbox------------------\n";
|
||||
|
||||
if (($zarafa1 eq 'enabled') || ($zarafa2 eq 'enabled'))
|
||||
{
|
||||
$OUT .= ":0\n";
|
||||
$OUT .= "| zarafa-dagent $USERNAME \n";
|
||||
}
|
||||
elsif (($sieveuser eq 'enabled') && ($sievesupport eq 'enabled'))
|
||||
{
|
||||
$OUT .= ":0 w\n";
|
||||
$OUT .= "\| /usr/libexec/dovecot/deliver\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$OUT .= ":0\n";
|
||||
$OUT .= "\$DEFAULT\n";
|
||||
}
|
||||
|
||||
$OUT .= "\n";
|
||||
$OUT .= "# ---- end of rules ------------------\n";
|
||||
}
|
32
root/etc/e-smith/templates-user/.qmail/50Filter
Normal file
32
root/etc/e-smith/templates-user/.qmail/50Filter
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
if ($qmail{FilterOrder})
|
||||
{
|
||||
|
||||
if ($props{MailFilter})
|
||||
{
|
||||
my $MailFilter = $props{MailFilter} || 'on';
|
||||
|
||||
return '# Procmail/Maildrop disabled for this user'
|
||||
if ($MailFilter eq 'bypass');
|
||||
}
|
||||
|
||||
if ($props{EmailForward})
|
||||
{
|
||||
my $EmailForward = $props{EmailForward} || 'on';
|
||||
|
||||
return '# Procmail/Maildrop disabled for forwarding mail purpose'
|
||||
if ($EmailForward eq 'forward');
|
||||
}
|
||||
|
||||
if ($qmail{FilterType})
|
||||
{
|
||||
return '| /usr/bin/procmail ~/.procmailrc ; if [ $? -ne 0 ] ; then exit -1; else exit 99; fi;'
|
||||
if ($qmail{FilterType} eq 'procmail');
|
||||
|
||||
return '| /usr/bin/maildrop ; if [ $? -ne 0 ] ; then exit -1; else exit 99; fi;'
|
||||
if ($qmail{FilterType} eq 'maildrop' );
|
||||
}
|
||||
|
||||
return '# Procmail/Maildrop disabled for all users'
|
||||
}
|
||||
}
|
36
root/etc/e-smith/templates-user/.qmail/76Filter
Normal file
36
root/etc/e-smith/templates-user/.qmail/76Filter
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
if ($qmail{FilterOrder})
|
||||
{
|
||||
return '# qmail FilterOrder enabled'
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if ($props{MailFilter})
|
||||
{
|
||||
my $MailFilter = $props{MailFilter} || 'on';
|
||||
|
||||
return '# Procmail/Maildrop disabled for this user'
|
||||
if ($MailFilter eq 'bypass');
|
||||
}
|
||||
|
||||
if ($props{EmailForward})
|
||||
{
|
||||
my $EmailForward = $props{EmailForward} || 'on';
|
||||
|
||||
return '# Procmail/Maildrop disabled for forwarding mail purpose'
|
||||
if ($EmailForward eq 'forward');
|
||||
}
|
||||
|
||||
if ($qmail{FilterType})
|
||||
{
|
||||
return '| /usr/bin/procmail ~/.procmailrc ; if [ $? -ne 0 ] ; then exit -1; else exit 99; fi;'
|
||||
if ($qmail{FilterType} eq 'procmail');
|
||||
|
||||
return '| /usr/bin/maildrop ; if [ $? -ne 0 ] ; then exit -1; else exit 99; fi;'
|
||||
if ($qmail{FilterType} eq 'maildrop' );
|
||||
}
|
||||
|
||||
return '# Procmail/Maildrop disabled for all users'
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user