diff --git a/install/sql/ispconfig3.sql b/install/sql/ispconfig3.sql index 09384519c32058cafc062ad9bcfc2cd5eab767c8..0b201152a61ded0edf93b998419233f81eda52c5 100644 --- a/install/sql/ispconfig3.sql +++ b/install/sql/ispconfig3.sql @@ -522,6 +522,7 @@ CREATE TABLE `mail_user` ( `homedir` varchar(255) NOT NULL, `autoresponder` enum('n','y') NOT NULL default 'n', `autoresponder_text` mediumtext NULL, + `move_junk` enum('n','y') NOT NULL default 'n', `custom_mailfilter` mediumtext, `postfix` enum('n','y') NOT NULL, `access` enum('n','y') NOT NULL, diff --git a/interface/web/mail/form/mail_user.tform.php b/interface/web/mail/form/mail_user.tform.php index 5ed0146139094d25f1ebe6cd37ad5e1dc9ed6a0e..a96d80c4fad5542abf96506989bd65ad14428d4f 100644 --- a/interface/web/mail/form/mail_user.tform.php +++ b/interface/web/mail/form/mail_user.tform.php @@ -202,7 +202,12 @@ $form["tabs"]['filter_records'] = array ( ################################## # Begin Datatable fields ################################## - + 'move_junk' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n',1 => 'y') + ), ################################## # ENDE Datatable fields ################################## diff --git a/interface/web/mail/lib/lang/en_mail_user.lng b/interface/web/mail/lib/lang/en_mail_user.lng index 5566be9d8cd33f9ecb05676cd9415bb7db5c1520..ccb965134fdb3ac1b5fa791173d399c7694de7a7 100644 --- a/interface/web/mail/lib/lang/en_mail_user.lng +++ b/interface/web/mail/lib/lang/en_mail_user.lng @@ -29,4 +29,5 @@ $wb["disableimap_txt"] = 'Disable IMAP'; $wb["disablepop3_txt"] = 'Disable POP3'; $wb["duplicate_alias_or_forward_txt"] = 'There is already an alias or forwrd with this email address.'; $wb["quota_error_value"] = 'Invalid quota value. Allowed values are: 0 for unlimited or numbers > 1'; +$wb["move_junk_txt"] = 'Move Spam Emails to Junk directory'; ?> diff --git a/interface/web/mail/templates/mail_user_mailfilter_edit.htm b/interface/web/mail/templates/mail_user_mailfilter_edit.htm index 404e62384d72a2287386413650e328a51c1096a5..9484dc699cf93d233bbd23d15f2ed4e9a73ff2c3 100644 --- a/interface/web/mail/templates/mail_user_mailfilter_edit.htm +++ b/interface/web/mail/templates/mail_user_mailfilter_edit.htm @@ -5,6 +5,12 @@
+
+

{tmpl_var name='move_junk_txt'}

+
+ {tmpl_var name='move_junk'} +
+
{tmpl_var name='filter_records'} diff --git a/server/conf/mailfilter_move_junk.master b/server/conf/mailfilter_move_junk.master new file mode 100644 index 0000000000000000000000000000000000000000..ef346c922c9c8bd59591785e161f916547c385f9 --- /dev/null +++ b/server/conf/mailfilter_move_junk.master @@ -0,0 +1,19 @@ + +SPAMDIR="Junk" +SPAMDIRFULL="$DEFAULT/.Junk" + +if ( /^X-Spam-Flag: YES$/ ) +{ + exception { + + `test -e $SPAMDIRFULL` + if ( $RETURNCODE != 0 ) + { + `maildirmake -f $SPAMDIR $DEFAULT` + `chown vmail:vmail -R $SPAMDIRFULL` + `chmod 0700 $SPAMDIRFULL` + `echo INBOX.$SPAMDIR >> $DEFAULT/courierimapsubscribed` + } + to "$SPAMDIRFULL/" + } +} \ No newline at end of file diff --git a/server/plugins-available/maildrop_plugin.inc.php b/server/plugins-available/maildrop_plugin.inc.php index b748c0fd0d2b29f84bdd40fb5543e15229b213a0..7b990c6ddc2a0abf7dc3ce81cba73d0df6980f9c 100644 --- a/server/plugins-available/maildrop_plugin.inc.php +++ b/server/plugins-available/maildrop_plugin.inc.php @@ -155,7 +155,8 @@ class maildrop_plugin { } // Write the custom mailfilter script, if mailfilter recipe has changed - if($data["old"]["custom_mailfilter"] != $data["new"]["custom_mailfilter"]) { + if($data["old"]["custom_mailfilter"] != $data["new"]["custom_mailfilter"] or + $data["old"]["move_junk"] != $data["new"]["move_junk"]) { $app->log("Mailfilter config has been changed",LOGLEVEL_DEBUG); if(trim($data["new"]["custom_mailfilter"]) != '') { // Delete the old filter recipe @@ -170,7 +171,14 @@ class maildrop_plugin { $email_parts = explode("@",$data["old"]["email"]); } $config_file_path = $this->mailfilter_config_dir.'/'.$email_parts[1].'/'.$email_parts[0].'/.mailfilter'; - file_put_contents($config_file_path,$data["new"]["custom_mailfilter"]); + + $mailfilter_content = ''; + if($data["new"]["move_junk"] == 'y') { + $mailfilter_content .= file_get_contents($conf["rootpath"].'/conf/mailfilter_move_junk.master')."\n"; + } + $mailfilter_content .= $data["new"]["custom_mailfilter"]; + + file_put_contents($config_file_path,$mailfilter_content); $app->log("Writing new custom Mailfiter".$config_file_path,LOGLEVEL_DEBUG); exec("chmod 770 $config_file_path"); exec("chown vmail $config_file_path");