Skip to content
Snippets Groups Projects
Commit f177a18a authored by Peter Rotich's avatar Peter Rotich
Browse files

Add bulk/auto-reply headers to outgoing emails as needed

parent 0cc04d87
Branches
Tags
No related merge requests found
......@@ -107,7 +107,20 @@ class Mailer {
'Date'=> date('D, d M Y H:i:s O'),
'Message-ID' => $messageId,
'X-Mailer' =>'osTicket Mailer'
);
);
//Set bulk/auto-response headers.
if($options && ($options['autoreply'] or $options['bulk'])) {
$headers+= array(
'X-Autoreply' => 'yes',
'X-Auto-Response-Suppress' => 'ALL, AutoReply',
'Auto-Submitted' => 'auto-replied');
if($options['bulk'])
$headers+= array('Precedence' => 'bulk');
else
$headers+= array('Precedence' => 'auto_reply');
}
$mime = new Mail_mime();
$mime->setTXTBody($body);
......
......@@ -242,7 +242,7 @@ class osTicket {
$email=$this->getConfig()->getDefaultEmail(); //will take the default email.
if($email) {
$email->send($to, $subject, $message);
$email->send($to, $subject, $message, null, array('bulk' => true));
} else {//no luck - try the system mail.
Email::sendmail($to, $subject, $message, sprintf('"osTicket Alerts"<%s>',$to));
}
......
......@@ -868,7 +868,7 @@ class Ticket {
$msg['body'] ="\n$tag\n\n".$msg['body'];
//TODO: add auto flags....be nice to mail servers and sysadmins!!
$email->send($this->getEmail(), $msg['subj'], $msg['body']);
$email->send($this->getEmail(), $msg['subj'], $msg['body'], null, array('autoreply' => true));
}
if(!($email=$cfg->getAlertEmail()))
......@@ -885,7 +885,7 @@ class Ticket {
//Alert admin??
if($cfg->alertAdminONNewTicket()) {
$alert = str_replace('%{recipient}', 'Admin', $msg['body']);
$email->send($cfg->getAdminEmail(), $msg['subj'], $alert);
$email->send($cfg->getAdminEmail(), $msg['subj'], $alert, null, array('bulk' => true));
$sentlist[]=$cfg->getAdminEmail();
}
......@@ -901,7 +901,7 @@ class Ticket {
foreach( $recipients as $k=>$staff){
if(!is_object($staff) || !$staff->isAvailable() || in_array($staff->getEmail(),$sentlist)) continue;
$alert = str_replace('%{recipient}', $staff->getFirstName(), $msg['body']);
$email->send($staff->getEmail(), $msg['subj'], $alert);
$email->send($staff->getEmail(), $msg['subj'], $alert, null, array('bulk' => true));
$sentlist[] = $staff->getEmail();
}
......@@ -934,7 +934,7 @@ class Ticket {
$msg = $this->replaceVars($msg,
array('signature' => ($dept && $dept->isPublic())?$dept->getSignature():''));
$email->send($this->getEmail(), $msg['subj'], $msg['body']);
$email->send($this->getEmail(), $msg['subj'], $msg['body'], null, array('bulk' => true));
}
$client= $this->getClient();
......@@ -997,7 +997,7 @@ class Ticket {
if($cfg->stripQuotedReply() && ($tag=$cfg->getReplySeparator()))
$msg['body'] ="\n$tag\n\n".$msg['body'];
$email->send($this->getEmail(), $msg['subj'], $msg['body']);
$email->send($this->getEmail(), $msg['subj'], $msg['body'], null, array('autoreply'=>true));
}
}
......@@ -1056,7 +1056,7 @@ class Ticket {
foreach( $recipients as $k=>$staff) {
if(!is_object($staff) || !$staff->isAvailable() || in_array($staff->getEmail(),$sentlist)) continue;
$alert = str_replace('%{recipient}', $staff->getFirstName(), $msg['body']);
$email->send($staff->getEmail(), $msg['subj'], $alert);
$email->send($staff->getEmail(), $msg['subj'], $alert, null, array('autoreply' => true));
$sentlist[] = $staff->getEmail();
}
}
......@@ -1109,7 +1109,7 @@ class Ticket {
foreach( $recipients as $k=>$staff){
if(!is_object($staff) || !$staff->isAvailable() || in_array($staff->getEmail(),$sentlist)) continue;
$alert = str_replace("%{recipient}", $staff->getFirstName(), $msg['body']);
$email->send($staff->getEmail(), $msg['subj'], $alert);
$email->send($staff->getEmail(), $msg['subj'], $alert, null, array('bulk' => true));
$sentlist[] = $staff->getEmail();
}
......@@ -1294,7 +1294,7 @@ class Ticket {
foreach( $recipients as $k=>$staff){
if(!is_object($staff) || !$staff->isAvailable() || in_array($staff->getEmail(),$sentlist)) continue;
$alert = str_replace('%{recipient}',$staff->getFirstName(), $msg['body']);
$email->send($staff->getEmail(), $msg['subj'], $alert);
$email->send($staff->getEmail(), $msg['subj'], $alert, null, array('bulk' => true));
$sentlist[] = $staff->getEmail();
}
}
......@@ -1453,7 +1453,7 @@ class Ticket {
foreach( $recipients as $k=>$staff){
if(!$staff || !$staff->getEmail() || !$staff->isAvailable() || in_array($staff->getEmail(), $sentlist)) continue;
$alert = str_replace('%{recipient}', $staff->getFirstName(), $msg['body']);
$email->send($staff->getEmail(), $msg['subj'], $alert);
$email->send($staff->getEmail(), $msg['subj'], $alert, null, array('bulk' => true));
$sentlist[] = $staff->getEmail();
}
}
......@@ -1503,7 +1503,7 @@ class Ticket {
$msg['body'] ="\n$tag\n\n".$msg['body'];
$attachments =($cfg->emailAttachments() && $files)?$this->getAttachments($respId, 'R'):array();
$email->send($this->getEmail(), $msg['subj'], $msg['body'], $attachments);
$email->send($this->getEmail(), $msg['subj'], $msg['body'], $attachments, array('autoreply' => true));
}
return $respId;
......@@ -1717,7 +1717,7 @@ class Ticket {
if(!$staff || !is_object($staff) || !$staff->getEmail() || !$staff->isAvailable()) continue;
if(in_array($staff->getEmail(),$sentlist) || ($staffId && $staffId==$staff->getId())) continue;
$alert = str_replace('%{recipient}',$staff->getFirstName(), $msg['body']);
$email->send($staff->getEmail(), $msg['subj'], $alert, $attachments);
$email->send($staff->getEmail(), $msg['subj'], $alert, $attachments, array('bulk' => true));
$sentlist[] = $staff->getEmail();
}
}
......@@ -2312,7 +2312,7 @@ class Ticket {
$msg['body'] ="\n$tag\n\n".$msg['body'];
$attachments =($cfg->emailAttachments() && $respId)?$ticket->getAttachments($respId,'R'):array();
$email->send($ticket->getEmail(), $msg['subj'], $msg['body'], $attachments);
$email->send($ticket->getEmail(), $msg['subj'], $msg['body'], $attachments, array('bulk' => true));
}
return $ticket;
......
......@@ -67,7 +67,7 @@ class Upgrader extends SetupWizard {
$subject = 'Upgrader Error';
if($email) {
$email->send($thisstaff->getEmail(), $subject, $error);
$email->send($thisstaff->getEmail(), $subject, $error, null, array('bulk' => true));
} else {//no luck - try the system mail.
Mailer::sendmail($thisstaff->getEmail(), $subject, $error, sprintf('"osTicket Alerts"<%s>', $thisstaff->getEmail()));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment