Skip to content

Commit b610819

Browse files
committed
Added: FS#873 - Option to redirect spam into a .Junk directory
1 parent 4a54265 commit b610819

File tree

6 files changed

+43
-3
lines changed

6 files changed

+43
-3
lines changed

install/sql/ispconfig3.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,7 @@ CREATE TABLE `mail_user` (
522522
`homedir` varchar(255) NOT NULL,
523523
`autoresponder` enum('n','y') NOT NULL default 'n',
524524
`autoresponder_text` mediumtext NULL,
525+
`move_junk` enum('n','y') NOT NULL default 'n',
525526
`custom_mailfilter` mediumtext,
526527
`postfix` enum('n','y') NOT NULL,
527528
`access` enum('n','y') NOT NULL,

interface/web/mail/form/mail_user.tform.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,12 @@
202202
##################################
203203
# Begin Datatable fields
204204
##################################
205-
205+
'move_junk' => array (
206+
'datatype' => 'VARCHAR',
207+
'formtype' => 'CHECKBOX',
208+
'default' => 'n',
209+
'value' => array(0 => 'n',1 => 'y')
210+
),
206211
##################################
207212
# ENDE Datatable fields
208213
##################################

interface/web/mail/lib/lang/en_mail_user.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ $wb["disableimap_txt"] = 'Disable IMAP';
2929
$wb["disablepop3_txt"] = 'Disable POP3';
3030
$wb["duplicate_alias_or_forward_txt"] = 'There is already an alias or forwrd with this email address.';
3131
$wb["quota_error_value"] = 'Invalid quota value. Allowed values are: 0 for unlimited or numbers > 1';
32+
$wb["move_junk_txt"] = 'Move Spam Emails to Junk directory';
3233
?>

interface/web/mail/templates/mail_user_mailfilter_edit.htm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ <h2><tmpl_var name="list_head_txt"></h2>
55

66
<div class="pnl_formsarea">
77
<fieldset class="inlineLabels">
8+
<div class="ctrlHolder">
9+
<p class="label">{tmpl_var name='move_junk_txt'}</p>
10+
<div class="multiField">
11+
{tmpl_var name='move_junk'}
12+
</div>
13+
</div>
814
</fieldset>
915

1016
{tmpl_var name='filter_records'}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
SPAMDIR="Junk"
3+
SPAMDIRFULL="$DEFAULT/.Junk"
4+
5+
if ( /^X-Spam-Flag: YES$/ )
6+
{
7+
exception {
8+
9+
`test -e $SPAMDIRFULL`
10+
if ( $RETURNCODE != 0 )
11+
{
12+
`maildirmake -f $SPAMDIR $DEFAULT`
13+
`chown vmail:vmail -R $SPAMDIRFULL`
14+
`chmod 0700 $SPAMDIRFULL`
15+
`echo INBOX.$SPAMDIR >> $DEFAULT/courierimapsubscribed`
16+
}
17+
to "$SPAMDIRFULL/"
18+
}
19+
}

server/plugins-available/maildrop_plugin.inc.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ function update($event_name,$data) {
155155
}
156156

157157
// Write the custom mailfilter script, if mailfilter recipe has changed
158-
if($data["old"]["custom_mailfilter"] != $data["new"]["custom_mailfilter"]) {
158+
if($data["old"]["custom_mailfilter"] != $data["new"]["custom_mailfilter"] or
159+
$data["old"]["move_junk"] != $data["new"]["move_junk"]) {
159160
$app->log("Mailfilter config has been changed",LOGLEVEL_DEBUG);
160161
if(trim($data["new"]["custom_mailfilter"]) != '') {
161162
// Delete the old filter recipe
@@ -170,7 +171,14 @@ function update($event_name,$data) {
170171
$email_parts = explode("@",$data["old"]["email"]);
171172
}
172173
$config_file_path = $this->mailfilter_config_dir.'/'.$email_parts[1].'/'.$email_parts[0].'/.mailfilter';
173-
file_put_contents($config_file_path,$data["new"]["custom_mailfilter"]);
174+
175+
$mailfilter_content = '';
176+
if($data["new"]["move_junk"] == 'y') {
177+
$mailfilter_content .= file_get_contents($conf["rootpath"].'/conf/mailfilter_move_junk.master')."\n";
178+
}
179+
$mailfilter_content .= $data["new"]["custom_mailfilter"];
180+
181+
file_put_contents($config_file_path,$mailfilter_content);
174182
$app->log("Writing new custom Mailfiter".$config_file_path,LOGLEVEL_DEBUG);
175183
exec("chmod 770 $config_file_path");
176184
exec("chown vmail $config_file_path");

0 commit comments

Comments
 (0)