From 04da14922eb6a6467a4d1d1242b9c0d7dc393c4c Mon Sep 17 00:00:00 2001
From: Peter Rotich <peter@osticket.com>
Date: Mon, 27 Jan 2014 17:14:45 +0000
Subject: [PATCH] Disable alerts to staff on bounces Exclude the
 auto-responding email from possible alerts sent to staff

---
 include/class.ticket.php | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/include/class.ticket.php b/include/class.ticket.php
index 673ddf309..4b54f03a2 100644
--- a/include/class.ticket.php
+++ b/include/class.ticket.php
@@ -782,6 +782,10 @@ class Ticket {
             $msg = $this->replaceVars($msg->asArray(), array('message' => $message));
 
             $recipients=$sentlist=array();
+            //Exclude the auto responding email just incase it's from staff member.
+            if ($message->isAutoResponse())
+                $sentlist[] = $this->getEmail();
+
             //Alert admin??
             if($cfg->alertAdminONNewTicket()) {
                 $alert = str_replace('%{recipient}', 'Admin', $msg['body']);
@@ -2151,8 +2155,8 @@ class Ticket {
 
         # Messages that are clearly auto-responses from email systems should
         # not have a return 'ping' message
-        if ($autorespond && $message && $message->isAutoReply())
-            $autorespond=false;
+        if ($autorespond && $message->isAutoReply())
+            $autorespond = false;
 
         //post canned auto-response IF any (disables new ticket auto-response).
         if ($vars['cannedResponseId']
@@ -2166,9 +2170,9 @@ class Ticket {
         if($autorespond && $dept && !$dept->autoRespONNewTicket())
             $autorespond=false;
 
-        //Don't send alerts to staff when the message is an auto reply
+        //Don't send alerts to staff when the message is a bounce
         //  this is necessary to avoid possible loop (especially on new ticket)
-        if ($alertstaff && $message->isAutoReply())
+        if ($alertstaff && $message->isAutoBounce())
             $alertstaff = false;
 
         /***** See if we need to send some alerts ****/
-- 
GitLab