Skip to content
Snippets Groups Projects
Commit a333026d authored by Jared Hancock's avatar Jared Hancock
Browse files

email: No bounces for system alerts

Send an empty return-path envelope when sending out system alerts. If they
should happen to bounce for any reason, they should not return to the system
and create tickets.
parent f7e19d6a
No related branches found
No related tags found
No related merge requests found
...@@ -25,11 +25,12 @@ class Mailer { ...@@ -25,11 +25,12 @@ class Mailer {
var $ht = array(); var $ht = array();
var $attachments = array(); var $attachments = array();
var $options = array();
var $smtp = array(); var $smtp = array();
var $eol="\n"; var $eol="\n";
function Mailer($email=null, $options=null) { function Mailer($email=null, array $options=array()) {
global $cfg; global $cfg;
if(is_object($email) && $email->isSMTPEnabled() && ($info=$email->getSMTPInfo())) { //is SMTP enabled for the current email? if(is_object($email) && $email->isSMTPEnabled() && ($info=$email->getSMTPInfo())) { //is SMTP enabled for the current email?
...@@ -46,6 +47,7 @@ class Mailer { ...@@ -46,6 +47,7 @@ class Mailer {
$this->email = $email; $this->email = $email;
$this->attachments = array(); $this->attachments = array();
$this->options = $options;
} }
function getEOL() { function getEOL() {
...@@ -114,7 +116,12 @@ class Mailer { ...@@ -114,7 +116,12 @@ class Mailer {
'X-Mailer' =>'osTicket Mailer', 'X-Mailer' =>'osTicket Mailer',
); );
if ($this->getEmail() instanceof Email) // Add in the options passed to the constructor
$options = ($options ?: array()) + $this->options;
if (isset($options['nobounce']) && $options['nobounce'])
$headers['Return-Path'] = '<>';
elseif ($this->getEmail() instanceof Email)
$headers['Return-Path'] = $this->getEmail()->getEmail(); $headers['Return-Path'] = $this->getEmail()->getEmail();
//Bulk. //Bulk.
...@@ -285,7 +292,7 @@ class Mailer { ...@@ -285,7 +292,7 @@ class Mailer {
//Emails using native php mail function - if DB connection doesn't exist. //Emails using native php mail function - if DB connection doesn't exist.
//Don't use this function if you can help it. //Don't use this function if you can help it.
function sendmail($to, $subject, $message, $from) { function sendmail($to, $subject, $message, $from) {
$mailer = new Mailer(); $mailer = new Mailer(null, array('notice'=>true, 'nobounce'=>true));
$mailer->setFromAddress($from); $mailer->setFromAddress($from);
return $mailer->send($to, $subject, $message); return $mailer->send($to, $subject, $message);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment