From 0e72f771b7babafb8df287b5ed8206f9ca15970b 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 | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/datamodel.itop-standard-email-synchro.xml b/datamodel.itop-standard-email-synchro.xml index a5de782..95ca607 100755 --- a/datamodel.itop-standard-email-synchro.xml +++ b/datamodel.itop-standard-email-synchro.xml @@ -1189,18 +1189,20 @@ EOF $this->sLastError = "Unknown caller (".$oEmail->sCallerEmail.")"; // if rejection reply - $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']; + $this->Trace("From: ".$sReplyFrom."\nTo: ".$sReplyTo."\n".$sReplySubject."\n\n".$sReplyBody); + $oRawEmail->SendAsAttachment($sReplyTo, $sReplyFrom, $sReplySubject, $sReplyBody); - $this->sLastError .= " - Replied to sender on ".date('r'); + $this->sLastError .= " - Replied to sender on ".date('r'); + } } // Send to contact