diff --git a/include/class.email.php b/include/class.email.php index e6b10c3892ece68f9d0410a77116f67cf7de61dd..c38144c4b1281fabf18ffd90b7e4a3937ff4cd90 100644 --- a/include/class.email.php +++ b/include/class.email.php @@ -142,7 +142,6 @@ class Email { function send($to, $subject, $message, $attachments=null, $options=null) { - $mailer = new Mailer($this); if($attachments) $mailer->addAttachments($attachments); @@ -150,6 +149,16 @@ class Email { return $mailer->send($to, $subject, $message, $options); } + function sendAutoReply($to, $subject, $message, $attachments=null, $options=array()) { + $options+= array('autoreply' => true); + return $this->send($to, $subject, $message, $attachments, $options); + } + + function sendAlert($to, $subject, $message, $attachments=null, $options=array()) { + $options+= array('bulk' => true); + return $this->send($to, $subject, $message, $attachments, $options); + } + function update($vars,&$errors) { $vars=$vars; $vars['cpasswd']=$this->getPasswd(); //Current decrypted password. diff --git a/include/class.filter.php b/include/class.filter.php index a70b4ddf04bedf2f71ae20a662308e71abb68856..b69a98987aeca7081a92f101e0dec00b50928bc1 100644 --- a/include/class.filter.php +++ b/include/class.filter.php @@ -875,7 +875,7 @@ class TicketFilter { 'Precedence' => array('AUTO_REPLY', 'BULK', 'JUNK', 'LIST'), 'Subject' => array('OUT OF OFFICE', 'AUTO-REPLY:', 'AUTORESPONSE'), 'X-Autoreply' => 'YES', - 'X-Auto-Response-Suppress' => 'OOF', + 'X-Auto-Response-Suppress' => array('ALL', 'DR', 'RN', 'NRN', 'OOF', 'AutoReply'), 'X-Autoresponse' => '', 'X-Auto-Reply-From' => '' ); diff --git a/include/class.mailer.php b/include/class.mailer.php index a227b8fc52951c563d56ccd4d59684149ae15336..57242e61605b77f241c5ec09973d28a1518b4836 100644 --- a/include/class.mailer.php +++ b/include/class.mailer.php @@ -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); diff --git a/include/class.osticket.php b/include/class.osticket.php index 86d206f212d6450db9755ac4f5c77926ff2a53c8..df0766f3d01076377ff9bd16b6ba78aa7ef429e0 100644 --- a/include/class.osticket.php +++ b/include/class.osticket.php @@ -242,7 +242,7 @@ class osTicket { $email=$this->getConfig()->getDefaultEmail(); //will take the default email. if($email) { - $email->send($to, $subject, $message); + $email->sendAlert($to, $subject, $message); } else {//no luck - try the system mail. Email::sendmail($to, $subject, $message, sprintf('"osTicket Alerts"<%s>',$to)); } diff --git a/include/class.ticket.php b/include/class.ticket.php index b4b7952b5f5740ab71301f324059a6eb7730eb98..5a3fd83f3883c432b17bf89d4ac08d6b4ee95de6 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -867,8 +867,7 @@ class Ticket { if($cfg->stripQuotedReply() && ($tag=$cfg->getReplySeparator())) $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->sendAutoReply($this->getEmail(), $msg['subj'], $msg['body']); } if(!($email=$cfg->getAlertEmail())) @@ -885,7 +884,7 @@ class Ticket { //Alert admin?? if($cfg->alertAdminONNewTicket()) { $alert = str_replace('%{recipient}', 'Admin', $msg['body']); - $email->send($cfg->getAdminEmail(), $msg['subj'], $alert); + $email->sendAlert($cfg->getAdminEmail(), $msg['subj'], $alert); $sentlist[]=$cfg->getAdminEmail(); } @@ -901,7 +900,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->sendAlert($staff->getEmail(), $msg['subj'], $alert); $sentlist[] = $staff->getEmail(); } @@ -934,7 +933,7 @@ class Ticket { $msg = $this->replaceVars($msg, array('signature' => ($dept && $dept->isPublic())?$dept->getSignature():'')); - $email->send($this->getEmail(), $msg['subj'], $msg['body']); + $email->sendAutoReply($this->getEmail(), $msg['subj'], $msg['body']); } $client= $this->getClient(); @@ -997,7 +996,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->sendAutoReply($this->getEmail(), $msg['subj'], $msg['body']); } } @@ -1056,7 +1055,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->sendAlert($staff->getEmail(), $msg['subj'], $alert); $sentlist[] = $staff->getEmail(); } } @@ -1109,7 +1108,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->sendAlert($staff->getEmail(), $msg['subj'], $alert); $sentlist[] = $staff->getEmail(); } @@ -1294,7 +1293,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->sendAlert($staff->getEmail(), $msg['subj'], $alert); $sentlist[] = $staff->getEmail(); } } @@ -1453,7 +1452,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->sendAlert($staff->getEmail(), $msg['subj'], $alert); $sentlist[] = $staff->getEmail(); } } @@ -1503,7 +1502,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->sendAutoReply($this->getEmail(), $msg['subj'], $msg['body'], $attachments); } return $respId; @@ -1717,7 +1716,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->sendAlert($staff->getEmail(), $msg['subj'], $alert, $attachments); $sentlist[] = $staff->getEmail(); } } diff --git a/include/class.upgrader.php b/include/class.upgrader.php index 012f88d1160bea1fb09d2104129d19e8fccebd3e..e437fcad7acd8d9b69045eb65655fa0f4ad835a5 100644 --- a/include/class.upgrader.php +++ b/include/class.upgrader.php @@ -67,7 +67,7 @@ class Upgrader extends SetupWizard { $subject = 'Upgrader Error'; if($email) { - $email->send($thisstaff->getEmail(), $subject, $error); + $email->sendAlert($thisstaff->getEmail(), $subject, $error); } else {//no luck - try the system mail. Mailer::sendmail($thisstaff->getEmail(), $subject, $error, sprintf('"osTicket Alerts"<%s>', $thisstaff->getEmail())); }