no, no, no, all wrong! all wrong!
Here, this should work:
CREATE CUSTOM TEMPLATE I:
-mkdir -p /etc/e-smith/templates-user-custom/.procmailrc
-cp /etc/e-smith/templates-user/.procmailrc/99_spamfilter_default
/etc/e-smith/templates-user-custom/.procmailrc
-in /etc/e-smith/templates-user/.procmailrc/99_spamfilter_default you should have
{
# check whether the User-Manager panel has placed the template files
# before creating one.
use esmith::config;
use esmith::db;
###pulls account info
my %accounts;
tie %accounts, 'esmith::config', '/home/e-smith/accounts';
my $ForwardAddress = db_get_prop(\%accounts, $USERNAME, "ForwardAddress");
$OUT = '';
unless ( -e '/etc/e-smith/templates-user/.procmailrc/99default' ) {
# Default rule
if ($ForwardAddress eq "")
{
$OUT .= "\n";
$OUT .= "# --------------------------\n";
$OUT .= "# all else goes to the inbox\n";
$OUT .= "# --------------------------\n";
$OUT .= ":0\n";
$OUT .= "\$DEFAULT\n";
}
else
{
$OUT .= "\n";
$OUT .= "# --------------------------\n";
$OUT .= "# all else gets forwarded\n";
$OUT .= "# --------------------------\n";
$OUT .= ":0\n";
$OUT .= "! $ForwardAddress\n";
}
} #end unless
}
This will forward all email to the FORWARDADDRESS field.
To capture the email and send a copy to the FORWARDADDRESS, put the following code underneath else (caution -this will fill up your HD space if users don't check regularly):
{
$OUT .= "\n";
$OUT .= "# --------------------------\n";
$OUT .= "# all else goes to the inbox & to FORWARDADDRESS\n";
$OUT .= "# --------------------------\n";
$OUT .= ":0 c\n";
$OUT .= "! $ForwardAddress\n";
$OUT .= ":0\n";
$OUT .= "\$DEFAULT\n";
}
CREATE CUSTOM TEMPLATE II:
#create a new filter to stop email looping
vi /etc/e-smith/templates-user-custom/.procmailrc/45_procmail_bounce
-in /etc/e-smith/templates-user-custom/.procmailrc/45_procmail_bounce you should have
{
# If a forwarded mail gets bounced,
# it's delivered into the local INBOX to prevent looping
$OUT .= " ";
$OUT .= "# ---------------------------------- ";
$OUT .= "# all bounced mail goes to the inbox ";
$OUT .= "# ---------------------------------- ";
$OUT .= ":0 ";
$OUT .= "* ^FROM_DAEMON ";
$OUT .= "* ^FROM_MAILER ";
$OUT .= "$DEFAULT ";
}
CLEAN UP & CREATE .procmailrc's
Then delete or move the existing fragment: /etc/e-smith/templates-user/.procmailrc/99default to ensure that the recreation picks up the changes.
Then update everyone's individual .procmailrc file with a:
/sbin/e-smith/signal-event spamfilter-init-procmail
USERACCOUNTS PANEL:
::to change the useraccounts panel to show the 'procmail' option
-vi /etc/e-smith/web/functions/useraccounts
-the emailforward section should look like this:
<field type="select" id="EmailForward" options="'local' =>
'DELIVER_EMAIL_LOCALLY', 'forward' => 'FORWARD_EMAIL',
'both' => 'DELIVER_AND_FORWARD', 'procmail' => 'Use procmail to
process mail'" validation="nonblank" value='local'>
<label>EMAIL_DELIVERY</label>
</field>
FORCE PROCMAIL FOR ALL OPTIONS:
-vi /etc/e-smith/templates-user-custom/.qmail/e-smithForward20
-the emailforward section should look like this:
if ($EmailForward eq "local")
{
$OUT .= "\n";
$OUT .= "| /usr/bin/procmail ~/.procmailrc \n";
}
elsif ($EmailForward eq 'forward')
{
$OUT .= "\n";
$OUT .= "| /usr/bin/procmail ~/.procmailrc \n";
}
elsif ($EmailForward eq 'both')
{
$OUT .= "\n";
$OUT .= "| /usr/bin/procmail ~/.procmailrc \n";
$OUT .= "./Maildir/\n";
}
elsif ($EmailForward eq 'procmail')
{
$OUT .= "\n";
$OUT .= "| /usr/bin/procmail ~/.procmailrc \n";
}
else
{
# this shouldn't happen - if it does, deliver through procmail
$OUT .= "\n";
$OUT .= "| /usr/bin/procmail ~/.procmailrc \n";
}
USERPANEL-FORWARDING:
::to always include the procmail option
-vi /etc/e-smith/web/functions/userpanel-forwarding
-the if/else statement for the procmail section should include 'procmail' in values and look like:
-values => ['local', 'forward', 'both', 'procmail'],
ADDITIONAL NOTES:
-the individual .procmailrc files are recreated with a /sbin/e-smith/signal-event user-modprocmail <username>
-this automatically happens in userpanel-forwarding but not in the useraccounts panel
-the .procmailrc files are only recreated if the $emailforward value is "procmail"; if another value (forward, local, both) then the changes only take place with a /sbin/e-smith/signal-event spamfilter-init-procmail (i'm guessing user-modprocmail is hard-coded to react this way).