From 27feacb99d1fb27d8e3cc155247aeb04fe940d44 Mon Sep 17 00:00:00 2001 From: Lars Kaltefleiter Date: Wed, 11 Aug 2021 12:20:21 +0200 Subject: [PATCH] Do not send a rejection reply in case of auto mails (such like delivery state info) --- datamodel.itop-standard-email-synchro.xml | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/datamodel.itop-standard-email-synchro.xml b/datamodel.itop-standard-email-synchro.xml index 5ecb86c..5fd1c1f 100755 --- a/datamodel.itop-standard-email-synchro.xml +++ b/datamodel.itop-standard-email-synchro.xml @@ -1196,15 +1196,20 @@ EOF $sRejectionReply = $this->Get('unknown_caller_rejection_reply'); if (!empty($sRejectionReply) && $oRawEmail) { - $sReplySubject = '[iTop] '.$oEmail->sSubject.' - '.$this->sLastError; - $sReplyBody = str_replace("\n", "
", $sRejectionReply); - $sReplyTo = $oEmail->sCallerEmail; - $aTo = $oRawEmail->GetTo(); - $sReplyFrom = $aTo[0]['email']; - $this->Trace("From: ".$sReplyFrom."\nTo: ".$sReplyTo."\n".$sReplySubject."\n\n".$sReplyBody); - $oRawEmail->SendAsAttachment($sReplyTo, $sReplyFrom, $sReplySubject, $sReplyBody); + // do not send rejection reply in case of an auto reply + if(!method_exists($oEmail, "IsAutoReplyEmail") || !$oEmail->IsAutoReplyEmail()){ + $sReplySubject = '[iTop] '.$oEmail->sSubject.' - '.$this->sLastError; + $sReplyBody = str_replace("\n", "
", $sRejectionReply); + $sReplyTo = $oEmail->sCallerEmail; + $aTo = $oRawEmail->GetTo(); + $sReplyFrom = $aTo[0]['email']; + $oRawEmail->SendAsAttachment($sReplyTo, $sReplyFrom, $sReplySubject, $sReplyBody); - $this->sLastError .= " - Replied to sender on ".date('r'); + $this->sLastError .= " - Replied to sender on ".date('r'); + } else { + $this->Trace("Email ignored as it was considered as an auto-reply"); + } + $this->Trace("From: ".$sReplyFrom."\nTo: ".$sReplyTo."\n".$sReplySubject."\n\n".$sReplyBody); } // Send to contact