Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > ISPConfig 2 > Tips/Tricks/Mods

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 22nd September 2007, 19: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:
{SPAM_COMMENT}/dev/null 
Change it to:
PHP Code:
{SPAM_COMMENT}.Junk

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__);
        if(!
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__);
        if(!
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
The Following 10 Users Say Thank You to grant For This Useful Post:
chancer (17th October 2007), dauz (18th November 2007), deathshadow (25th March 2008), falko (23rd September 2007), goldstift (18th January 2008), jbravo (19th November 2007), madmucho (14th October 2007), MTvermoes (20th January 2008), torusturtle (5th October 2007), wa4bro (25th October 2008)
Sponsored Links
  #2  
Old 14th October 2007, 00:30
madmucho madmucho is offline
Senior Member
 
Join Date: Oct 2006
Location: Czech republic, Karlovy Vary
Posts: 158
Thanks: 81
Thanked 11 Times in 11 Posts
Send a message via ICQ to madmucho
Default

That is exaclty what i looking for thanks

Any idea how to add this in listbox and extend default configuration?
accept
discard
move to junk ?
Reply With Quote
  #3  
Old 17th October 2007, 19:34
chancer chancer is offline
Member
 
Join Date: Sep 2007
Posts: 88
Thanks: 6
Thanked 1 Time in 1 Post
Default

Quote:
(The forums are doing some weird wrapping on that code. The 3 if statements should be on 1 line each.)
They do when you copy and paste them into a text editor - but they do wrap because they are very long.

Very useful mod, thanks. Exactly what I was alluding to in my original thread.
Reply With Quote
  #4  
Old 19th November 2007, 06:48
ramansivia ramansivia is offline
Junior Member
 
Join Date: Nov 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Re Not Working

Hello, I have followed Step By Step

But i still have no luck with moving spam to junk folder, Even "Junk" folder is not created on webmail,

in Admin page i do see , it is changed from Accpect lo leaveg in inbox and move to junk , but when i make it move junk that spam message jst get deleted nothing comes in Junk folder even if i create Junk folder by my self

what could be worng ?

I really like the idea , and i would like it to work i'm using 2.18 of ispconfig and i just followed setting that was put by ispconfig site to install the ispconfig

thanks
Reply With Quote
  #5  
Old 19th November 2007, 12:56
jbravo jbravo is offline
Member
 
Join Date: Nov 2007
Location: Poland
Posts: 81
Thanks: 12
Thanked 3 Times in 2 Posts
Default

Works like a charm (ISPConfig 2.2.18, squirreloutlook 1.4.8)! Had to subscribe new folders in squirreloutlook user interface after login and setup them (deleted mails -> trash, sent mails -> sent).

Big thanks!
Reply With Quote
  #6  
Old 20th November 2007, 06:02
ramansivia ramansivia is offline
Junior Member
 
Join Date: Nov 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default JUNK Folder No Luck

Thanks for reply ,

I do see sent, trash, inbox, and i see its in user infer.. but there is no option for junk folder,

1) when i make new email account, Junk folder is not created

2) when i choice option to move spam to junk folder, rather then redirect mail to junk it just delete it message, (as it should do according to ISP setup, either mail in inbox or delete it )

Is there something wrong in my setup , or i'm missing something
thanks

Raman
Reply With Quote
  #7  
Old 21st November 2007, 20:38
jbravo jbravo is offline
Member
 
Join Date: Nov 2007
Location: Poland
Posts: 81
Thanks: 12
Thanked 3 Times in 2 Posts
Default

Quote:
Originally Posted by ramansivia
Thanks for reply ,

I do see sent, trash, inbox, and i see its in user infer.. but there is no option for junk folder,

1) when i make new email account, Junk folder is not created
They don't appear on webmail at the beginning (i'm using sqiuirrel). Check via shell login what's inside user's Maildir.

Quote:
Originally Posted by ramansivia
2) when i choice option to move spam to junk folder, rather then redirect mail to junk it just delete it message, (as it should do according to ISP setup, either mail in inbox or delete it )

Is there something wrong in my setup , or i'm missing something
thanks

Raman
I'm missing someting? There should be choice to leave in inbox or move to junk - not move/redirect.

Also check twice steps described in posts above and make edited files backup first
Reply With Quote
  #8  
Old 7th January 2008, 11:01
MTvermoes MTvermoes is offline
Junior Member
 
Join Date: Dec 2007
Posts: 17
Thanks: 1
Thanked 10 Times in 5 Posts
Default Auto Remove Junk Older than 14 Days

I have implemented the move spam to Junk, and ran into a problem :
Users getting their mail with pop3 don't see all the spam in .Junk Folder.
The size of the junk folder will soon exeed the users disk quota.
So i found a little script on the net, and modified it a bit for use with ISPConfig.
It will remove Messages older than 14 days from users .Junk folder.
I run it daily via cron.

cat /etc/cron.daily/purge.junk
Code:
#!/bin/sh

HOURS=$((2 * 24 * 7))

for domain in /var/www/*
do
        if [ -d "$domain"/user ]
                then
                        cd $domain/user
                        for user in *
                        do
                                if [ -d "$user/Maildir/.Junk" ]
                                then
                                        tmpwatch -m $HOURS $user/Maildir/.Junk/{cur,new}
                                fi
                        done
                        cd /var/www
        fi
done
Edit(11 Jan 2008):

You might want to add :
/etc/init.d/dovecot restart
to the script, to make dovecot rebuild message indexes.



/Mark

Last edited by MTvermoes; 11th January 2008 at 22:55.
Reply With Quote
The Following 2 Users Say Thank You to MTvermoes For This Useful Post:
falko (8th January 2008), till (7th January 2008)
  #9  
Old 17th January 2008, 20:49
grafzahl grafzahl is offline
Junior Member
 
Join Date: Jan 2008
Posts: 10
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Hello,

unfortunately there are no tmpwatch rpm for SuSe Linux and tmpwatch sources are hard to find.

My way for SuSe 10.1 is to replace
Code:
tmpwatch -m $HOURS $user/Maildir/.Junk/{cur,new}
with
Code:
find $user/Maildir/.Spam/cur -mtime +30 -exec rm {} \;
find $user/Maildir/.Spam/new -mtime +30 -exec rm {} \;
The "+30" in code mean 30 days. So you dont need variable HOURS.

Greets from Germany
Grafzahl
Reply With Quote
  #10  
Old 20th January 2008, 18:43
MTvermoes MTvermoes is offline
Junior Member
 
Join Date: Dec 2007
Posts: 17
Thanks: 1
Thanked 10 Times in 5 Posts
 
Default

To install tmpwatch from source :
Code:
cd /usr/src
wget http://linux.bononline.nl/linux/tmpwatch/src/tmpwatch-2.9.0.tar.gz
tar xvzf tmpwatch-2.9.0.tar.gz
cd tmpwatch-2.9.0
make
make install
This will install tmpwatch with Prefix /usr/local

/Mark
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Postfix & mail forwarding loop varnik Server Operation 21 9th December 2008 16:13
Postfix reject connections gabrix Server Operation 27 25th January 2007 09:37
postfix-tls sasl2 mysql courier-authmysql gabrix Server Operation 4 12th January 2007 23:09
Core 4: Error Messages on Fresh Install re CTX/SSL jjw Installation/Configuration 30 6th September 2006 13:16
Virtual Users And Domains With Postfix, Courier And MySQL (+ SMTP-AUTH, Quota, SpamAs ebbay Installation/Configuration 9 4th March 2006 12:47


All times are GMT +2. The time now is 07:23.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.