--- smeserver-mailsorting-1.2/root/etc/e-smith/templates-user/.procmailrc/00setup.zarafaprocmail 2009-02-21 21:05:05.000000000 +1100 +++ smeserver-mailsorting-1.2/root/etc/e-smith/templates-user/.procmailrc/00setup 2009-02-21 23:18:05.000000000 +1100 @@ -0,0 +1,14 @@ +{ + # vim: ft=perl: + + use esmith::AccountsDB; + our $adb = esmith::AccountsDB->open_ro or die "Couldn't open AccountsDB"; + + $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'; + + $OUT = ''; +} --- smeserver-mailsorting-1.2/root/etc/e-smith/templates-user/.procmailrc/40global.zarafaprocmail 2009-02-21 15:19:36.000000000 +1100 +++ smeserver-mailsorting-1.2/root/etc/e-smith/templates-user/.procmailrc/40global 2009-02-21 23:48:43.000000000 +1100 @@ -2,19 +2,6 @@ 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'; - my %processmail; tie %processmail, 'esmith::config', '/home/e-smith/db/processmail'; @@ -84,15 +71,18 @@ } ##construct the deliver line - if ($action eq 'sort') + if (($action eq 'sort') || ($action eq 'create')) { # to a folder - $deliver = "\$MAILDIR/".'.'."$deliver"."/"; - } - elsif ($action eq 'create') - { - # to a folder - $deliver = "\$MAILDIR/".'.'."$deliver"."/"; + 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') { @@ -114,7 +104,15 @@ if ($action2 eq 'sort') { # to a folder - $deliver = "\$MAILDIR/".'.'."$deliver2"."/"; + 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') { --- smeserver-mailsorting-1.2/root/etc/e-smith/templates-user/.procmailrc/15log.zarafaprocmail 2009-02-21 21:19:25.000000000 +1100 +++ smeserver-mailsorting-1.2/root/etc/e-smith/templates-user/.procmailrc/15log 2009-02-22 00:07:29.000000000 +1100 @@ -2,20 +2,6 @@ use esmith::config; use esmith::db; - my %accounts; - tie %accounts, 'esmith::config', '/home/e-smith/db/accounts'; - - # get $USERNAME from esmith::config - put there by the - # email-update-user action as a temporary variable - 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'; - my %processmail; tie %processmail, 'esmith::config', '/home/e-smith/db/processmail'; @@ -43,4 +29,4 @@ $OUT .= "LOGABSTRACT=all\n"; $OUT .= "LOGFILE=\$HOME/procmail.log\n"; } -} \ No newline at end of file +} --- smeserver-mailsorting-1.2/root/etc/e-smith/templates-user/.procmailrc/25options.zarafaprocmail 2009-02-21 23:25:50.000000000 +1100 +++ smeserver-mailsorting-1.2/root/etc/e-smith/templates-user/.procmailrc/25options 2009-02-21 23:26:47.000000000 +1100 @@ -1,31 +1,6 @@ { -# use esmith::config; -# use esmith::db; -# -# my %accounts; -# tie %accounts, 'esmith::config', '/home/e-smith/db/accounts'; -# -# # get $USERNAME from esmith::config - put there by the -# # email-update-user action as a temporary variable -# 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'; -# -# my %processmail; -# tie %processmail, 'esmith::config', '/home/e-smith/db/processmail'; -# -# # delete duplicates -# my $deldups = db_get_prop(\%processmail, $USERNAME, "deldups") || ''; -# if ($deldups eq 'yes') -# { $OUT .= "\n"; $OUT .= "# ---- delete duplicates -------\n"; $OUT .= ":0 Wh: msgid.lock\n"; $OUT .= "| \$FORMAIL -D 8192 msgid.cache\n"; -# } -} \ No newline at end of file +} --- smeserver-mailsorting-1.2/root/etc/e-smith/templates-user/.procmailrc/90default.zarafaprocmail 2009-02-21 21:26:08.000000000 +1100 +++ smeserver-mailsorting-1.2/root/etc/e-smith/templates-user/.procmailrc/90default 2009-02-21 23:48:00.000000000 +1100 @@ -1,8 +1,18 @@ { $OUT .= "\n"; - $OUT .= "# ---- to the inbox------------------\n"; - $OUT .= ":0\n"; - $OUT .= "\$DEFAULT\n"; + $OUT .= "# ---- to the inbox------------------\n"; + + if (($zarafa1 eq 'enabled') || ($zarafa2 eq 'enabled')) + { + $OUT .= ":0\n"; + $OUT .= "| zarafa-dagent $USERNAME \n"; + } + else + { + $OUT .= ":0\n"; + $OUT .= "\$DEFAULT\n"; + } + $OUT .= "\n"; $OUT .= "# ---- end of rules ------------------\n"; } --- smeserver-mailsorting-1.2/root/etc/e-smith/templates-user/.procmailrc/60user.zarafaprocmail 2009-02-21 17:39:47.000000000 +1100 +++ smeserver-mailsorting-1.2/root/etc/e-smith/templates-user/.procmailrc/60user 2009-02-21 23:48:59.000000000 +1100 @@ -2,26 +2,9 @@ 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'; - my %processmail; tie %processmail, 'esmith::config', '/home/e-smith/db/processmail'; - my $sep = '.'; - # get users rules my @pmRules = (); foreach (sort keys %processmail) @@ -51,7 +34,7 @@ my $action = db_get_prop(\%processmail, $pmRule, "action") || ''; my $action2 = db_get_prop(\%processmail, $pmRule, "action2") || ''; #allow for spaces _ to \_ - $deliver =~ s/ /\\ /g; + $deliver =~ s/ /\\ /g; $deliver2 =~ s/ /\\ /g; foreach ($basis, $basis2) @@ -88,16 +71,19 @@ } } - ## construct the deliver line - if ($action eq 'sort') + ##construct the deliver line + if (($action eq 'sort') || ($action eq 'create')) { # to a folder - $deliver = "\$MAILDIR/"."$sep"."$deliver"."/"; - } - elsif ($action eq 'create') - { - # to a folder - $deliver = "\$MAILDIR/"."$sep"."$deliver"."/"; + 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') { @@ -115,11 +101,19 @@ $deliver = "$deliver"; } - ## construct the 2nd deliver line + ##construct the 2nd deliver line if ($action2 eq 'sort') { # to a folder - $deliver2 = "\$MAILDIR/"."$sep"."$deliver2"."/"; + 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') {