View Single Post
Old 22nd September 2007, 18:25
grant grant is offline
Junior Member
Join Date: Sep 2007
Posts: 14
Thanks: 0
Thanked 15 Times in 4 Posts
Default Move junk mail to a folder instead of deleting

With SpamAssassin turned on, the default spam strategy options let you either leave junk mail in your inbox (accept), or delete it completely (discard).

I hate having my mail deleted for me. I rarely have false positives, but I'd rather see the junk mail I'm getting to be able to make sure.

These changes allow you to change the behavior to either:
  • Leave it in your inbox
  • Move it to the Junk folder

This guide also assumes that your clients are using IMAP to access their mail, or at least have access to a web client that is using IMAP, so they can see the Junk folder. It also assumes that you are using Maildirs.

First change the behavior of spamassassin. Edit /root/ispconfig/isp/conf/spamassassin.rc.master.
Find the line:
PHP Code:
Change it to:
PHP Code:

Now make sure that the Junk folders are created automatically. We can't move mail to a folder that doesn't exist. Edit /root/ispconfig/scripts/lib/classes/ispconfig_procmail.lib.php.
Find the line (around 107) that reads:
PHP Code:
if(!is_dir($web_path."/user/".$user_username."/Maildir")) $mod->log->caselog("maildirmake ".$web_path."/user/".$user_username."/Maildir &> /dev/null""maildirmake ".$web_path."/user/".$user_username."/Maildir &> /dev/null"__LINE__); 
Below it add:

PHP Code:
# Create Junk, Send, Trash folders
if(!is_dir($web_path."/user/".$user_username."/Maildir/.Junk")) $mod->log->caselog("maildirmake -f Junk ".$web_path."/user/".$user_username."/Maildir &> /dev/null""maildirmake -f Junk ".$web_path."/user/".$user_username."/Maildir &> /dev/null"__LINE__);
is_dir($web_path."/user/".$user_username."/Maildir/.Sent")) $mod->log->caselog("maildirmake -f Sent ".$web_path."/user/".$user_username."/Maildir &> /dev/null""maildirmake -f Send ".$web_path."/user/".$user_username."/Maildir &> /dev/null"__LINE__);
is_dir($web_path."/user/".$user_username."/Maildir/.Trash")) $mod->log->caselog("maildirmake -f Trash ".$web_path."/user/".$user_username."/Maildir &> /dev/null""maildirmake -f Trash ".$web_path."/user/".$user_username."/Maildir &> /dev/null"__LINE__); 
(The forums are doing some weird wrapping on that code. The 3 if statements should be on 1 line each.)

Edit /home/admispconfig/ispconfig/web/isp_manager/lib/lang/en.lng
Find the lines:
PHP Code:
$wb["accept"] = 'accept';
$wb["discard"] = 'discard'
Change them to:
PHP Code:
$wb["accept"] = 'Leave in Inbox';
$wb["discard"] = 'Move to Junk'
Edit /home/admispconfig/ispconfig/web/mailuser/lib/lang/en.lng
Find the lines:
PHP Code:
$wb["txt_accept"] = "accept";
$wb["txt_discard"] = "discard"
Change them to:
PHP Code:
$wb["txt_accept"] = "Leave in Inbox";
$wb["txt_discard"] = "Move to Junk"
Now make a small change to in ISPConfig to make it refresh all your users. It should automatically create Junk, Sent and Trash folders for everyone. When then change their spam settings, they will now see the options "Leave in Inbox" and "Move to Junk" instead of accept and discard.
Reply With Quote
Sponsored Links