Skip to content

Commit 26c5282

Browse files
author
wyrie
committed
Implemented: FS#1003 - Autoresponder: Start and end date (Server)
1 parent da488d7 commit 26c5282

File tree

2 files changed

+26
-11
lines changed

2 files changed

+26
-11
lines changed

server/conf/autoresponder.master

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@ if ($RETURNCODE==1)
66
{
77
if (!/^X-Spam-Flag: YES/:h )
88
{
9-
RESPOND="{vmail_mailbox_base}/mailfilters/$HOST/$USER/.vacation.msg"
10-
RESPONDDB="{vmail_mailbox_base}/mailfilters/$HOST/$USER/.vacation.lst"
11-
12-
# The following must be one contiguous line
13-
cc "| mailbot -t $RESPOND -d $RESPONDDB -D 1 \
14-
-A 'From: $RECIPIENT' -s 'Auto Response: from $RECIPIENT' \
15-
/usr/sbin/sendmail -t -f ''"
9+
NOW=time
10+
if ({start_date} lt $NOW && {end_date} gt $NOW)
11+
{
12+
RESPOND="{vmail_mailbox_base}/mailfilters/$HOST/$USER/.vacation.msg"
13+
RESPONDDB="{vmail_mailbox_base}/mailfilters/$HOST/$USER/.vacation.lst"
14+
15+
# The following must be one contiguous line
16+
cc "| mailbot -t $RESPOND -d $RESPONDDB -D 1 \
17+
-A 'From: $RECIPIENT' -s 'Auto Response: from $RECIPIENT' \
18+
/usr/sbin/sendmail -t -f ''"
19+
}
1620
}
1721
}
1822
}

server/plugins-available/maildrop_plugin.inc.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,12 @@ function update($event_name,$data) {
104104
exec("chmod 770 ".$this->mailfilter_config_dir.'/'.$email_parts[1].'/'.$email_parts[0]);
105105
}
106106

107-
108107
// Check if something has been changed regarding the autoresponders
109108
if($data["old"]["autoresponder_text"] != $data["new"]["autoresponder_text"]
110109
or $data["old"]["autoresponder"] != $data["new"]["autoresponder"]
111-
or (isset($data["new"]["email"]) and $data["old"]["email"] != $data["new"]["email"])) {
110+
or (isset($data["new"]["email"]) and $data["old"]["email"] != $data["new"]["email"])
111+
or $data["old"]["autoresponder_start_date"] != $data["new"]["autoresponder_start_date"]
112+
or $data["old"]["autoresponder_end_date"] != $data["new"]["autoresponder_end_date"]) {
112113

113114
// We delete the old autoresponder, if it exists
114115
$email_parts = explode("@",$data["old"]["email"]);
@@ -123,8 +124,9 @@ function update($event_name,$data) {
123124
$file = $this->mailfilter_config_dir.'/'.$email_parts[1].'/'.$email_parts[0].'/.vacation.msg';
124125
if(is_file($file)) unlink($file) or $app->log("Unable to delete file: $file",LOGLEVEL_WARN);
125126
$file = $this->mailfilter_config_dir.'/'.$email_parts[1].'/'.$email_parts[0].'/.autoresponder';
126-
if(is_file($file)) unlink($file) or $app->log("Unable to delete file: $file",LOGLEVEL_WARN);
127-
127+
if(is_file($file)) unlink($ar_file) or $app->log("Unable to delete file: $ar_file",LOGLEVEL_WARN);
128+
129+
128130
//Now we create the new autoresponder, if it is enabled
129131
if($data["new"]["autoresponder"] == 'y') {
130132
if(isset($data["new"]["email"])) {
@@ -136,6 +138,15 @@ function update($event_name,$data) {
136138
// Load the master template
137139
$tpl = file_get_contents($conf["rootpath"].'/conf/autoresponder.master');
138140
$tpl = str_replace('{vmail_mailbox_base}',$mail_config["homedir_path"],$tpl);
141+
142+
if ($data["new"]["autoresponder_start_date"] != '0000-00-00 00:00:00') { // Dates have been set
143+
$tpl = str_replace('{start_date}',strtotime($data["new"]["autoresponder_start_date"]),$tpl);
144+
$tpl = str_replace('{end_date}',strtotime($data["new"]["autoresponder_end_date"]),$tpl);
145+
} else {
146+
$tpl = str_replace('{start_date}',-7200,$tpl);
147+
$tpl = str_replace('{end_date}',2147464800,$tpl);
148+
}
149+
139150
// Write the config file.
140151
$config_file_path = $this->mailfilter_config_dir.'/'.$email_parts[1].'/'.$email_parts[0].'/.autoresponder';
141152
file_put_contents($config_file_path,$tpl);

0 commit comments

Comments
 (0)