From 2a704f6cfc90c5cb0c037bffea0f70cad358a829 Mon Sep 17 00:00:00 2001 From: tbrehm <t.brehm@ispconfig.org> Date: Tue, 29 Jun 2010 10:54:09 +0000 Subject: [PATCH] Implemented: FS#891 - Email Forward check box to Leave a copy. --- install/sql/ispconfig3.sql | 1 + interface/web/mail/form/mail_user.tform.php | 12 ++++++++++++ interface/web/mail/lib/lang/en_mail_user.lng | 2 ++ .../web/mail/templates/mail_user_mailbox_edit.htm | 4 ++++ server/conf/sieve_filter.master | 6 ++++++ server/plugins-available/maildeliver_plugin.inc.php | 4 +++- server/plugins-available/maildrop_plugin.inc.php | 11 +++++++++-- 7 files changed, 37 insertions(+), 3 deletions(-) diff --git a/install/sql/ispconfig3.sql b/install/sql/ispconfig3.sql index 227b014cd..2c0caf291 100644 --- a/install/sql/ispconfig3.sql +++ b/install/sql/ispconfig3.sql @@ -560,6 +560,7 @@ CREATE TABLE `mail_user` ( `gid` int(11) unsigned NOT NULL default '5000', `maildir` varchar(255) NOT NULL default '', `quota` bigint(20) NOT NULL default '-1', + `cc` varchar(255) NOT NULL default '', `homedir` varchar(255) NOT NULL, `autoresponder` enum('n','y') NOT NULL default 'n', `autoresponder_start_date` datetime NOT NULL default '0000-00-00 00:00:00', diff --git a/interface/web/mail/form/mail_user.tform.php b/interface/web/mail/form/mail_user.tform.php index 5214b6209..06fa18a23 100644 --- a/interface/web/mail/form/mail_user.tform.php +++ b/interface/web/mail/form/mail_user.tform.php @@ -110,6 +110,18 @@ $form["tabs"]['mailuser'] = array ( 'width' => '30', 'maxlength' => '255' ), + 'cc' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'REGEX', + 'regex' => '/^(\w+[\w\.\-\+]*\w{0,}@\w+[\w.-]*\w+\.[a-z]{2,10}){0,1}$/i', + 'errmsg'=> 'cc_error_isemail'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), 'maildir' => array ( 'datatype' => 'VARCHAR', 'formtype' => 'TEXT', diff --git a/interface/web/mail/lib/lang/en_mail_user.lng b/interface/web/mail/lib/lang/en_mail_user.lng index 7ce7b52f9..d49bfb722 100644 --- a/interface/web/mail/lib/lang/en_mail_user.lng +++ b/interface/web/mail/lib/lang/en_mail_user.lng @@ -37,4 +37,6 @@ $wb["move_junk_txt"] = 'Move Spam Emails to Junk directory'; $wb["name_txt"] = 'Realname'; $wb["name_optional_txt"] = '(Optional)'; $wb['autoresponder_active'] = 'Enable the autoresponder'; +$wb['cc_txt'] = 'Send copy to'; +$wb['cc_error_isemail'] = 'The "Send copy to" field does not conatin a valid email address'; ?> diff --git a/interface/web/mail/templates/mail_user_mailbox_edit.htm b/interface/web/mail/templates/mail_user_mailbox_edit.htm index 708ff8a9e..ba0c4d829 100644 --- a/interface/web/mail/templates/mail_user_mailbox_edit.htm +++ b/interface/web/mail/templates/mail_user_mailbox_edit.htm @@ -30,6 +30,10 @@ <label for="quota">{tmpl_var name='quota_txt'}</label> <input name="quota" id="quota" value="{tmpl_var name='quota'}" size="30" maxlength="255" type="text" class="textInput formLengthLimit" /><p class="formInputUnity"> MB</p> </div> + <div class="ctrlHolder"> + <label for="name">{tmpl_var name='cc_txt'}</label> + <input name="cc" id="cc" value="{tmpl_var name='cc'}" size="30" maxlength="255" type="text" class="textInput" /> {tmpl_var name='name_optional_txt'} + </div> <div class="ctrlHolder"> <label for="policy">{tmpl_var name='policy_txt'}</label> <select name="policy" id="policy" class="selectInput"> diff --git a/server/conf/sieve_filter.master b/server/conf/sieve_filter.master index c3393cf7c..2b4a9fc2f 100644 --- a/server/conf/sieve_filter.master +++ b/server/conf/sieve_filter.master @@ -1,6 +1,12 @@ require ["fileinto", "regex", "vacation"]; +<tmpl_if name="cc"> +# Send a copy of email to +redirect "<tmpl_var name='cc'>"; +keep; +</tmpl_if> + <tmpl_if name="move_junk" op="==" value="y"> # Move spam to spam folder if header :contains "X-Spam-Flag" "YES" { diff --git a/server/plugins-available/maildeliver_plugin.inc.php b/server/plugins-available/maildeliver_plugin.inc.php index 7fc8a4e76..b2a114623 100644 --- a/server/plugins-available/maildeliver_plugin.inc.php +++ b/server/plugins-available/maildeliver_plugin.inc.php @@ -89,7 +89,9 @@ class maildeliver_plugin { or $data["old"]["autoresponder"] != $data["new"]["autoresponder"] or (isset($data["new"]["email"]) and $data["old"]["email"] != $data["new"]["email"]) or $data["old"]["autoresponder_start_date"] != $data["new"]["autoresponder_start_date"] - or $data["old"]["autoresponder_end_date"] != $data["new"]["autoresponder_end_date"]) { + or $data["old"]["autoresponder_end_date"] != $data["new"]["autoresponder_end_date"] + or $data["old"]["cc"] != $data["new"]["cc"] + ) { $app->log("Mailfilter config has been changed",LOGLEVEL_DEBUG); diff --git a/server/plugins-available/maildrop_plugin.inc.php b/server/plugins-available/maildrop_plugin.inc.php index 58cbaa477..6296653b6 100644 --- a/server/plugins-available/maildrop_plugin.inc.php +++ b/server/plugins-available/maildrop_plugin.inc.php @@ -166,8 +166,10 @@ class maildrop_plugin { } // Write the custom mailfilter script, if mailfilter recipe has changed - if($data["old"]["custom_mailfilter"] != $data["new"]["custom_mailfilter"] or - $data["old"]["move_junk"] != $data["new"]["move_junk"]) { + if($data["old"]["custom_mailfilter"] != $data["new"]["custom_mailfilter"] + or $data["old"]["move_junk"] != $data["new"]["move_junk"] + or $data["old"]["cc"] != $data["new"]["cc"]) { + $app->log("Mailfilter config has been changed",LOGLEVEL_DEBUG); if(trim($data["new"]["custom_mailfilter"]) != '' or $data["new"]["move_junk"] != 'n') { // Delete the old filter recipe @@ -184,6 +186,11 @@ class maildrop_plugin { $config_file_path = $this->mailfilter_config_dir.'/'.$email_parts[1].'/'.$email_parts[0].'/.mailfilter'; $mailfilter_content = ''; + + if($data["new"]["cc"] != '') { + $mailfilter_content .= "cc \"!".$data["new"]["cc"]."\"\n"; + } + if($data["new"]["move_junk"] == 'y') { $mailfilter_content .= file_get_contents($conf["rootpath"].'/conf/mailfilter_move_junk.master')."\n"; } -- GitLab