From 96296fe2116325b39afda0b86ee9bdf8f163222a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eric=20Espi=C3=A9?= Date: Thu, 2 Nov 2017 16:43:00 +0000 Subject: [PATCH] Duration KPI added on sending email. SVN:trunk[5125] --- core/email.class.inc.php | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/core/email.class.inc.php b/core/email.class.inc.php index 752f3ef03..3036f5125 100644 --- a/core/email.class.inc.php +++ b/core/email.class.inc.php @@ -195,18 +195,29 @@ class EMail $aFailedRecipients = array(); $this->m_oMessage->setMaxLineLength(0); - $iSent = $oMailer->send($this->m_oMessage, $aFailedRecipients); - if ($iSent === 0) + $oKPI = new ExecutionKPI(); + try { - // Beware: it seems that $aFailedRecipients sometimes contains the recipients that actually received the message !!! - IssueLog::Warning('Email sending failed: Some recipients were invalid, aFailedRecipients contains: '.implode(', ', $aFailedRecipients)); - $aIssues = array('Some recipients were invalid.'); - return EMAIL_SEND_ERROR; + $iSent = $oMailer->send($this->m_oMessage, $aFailedRecipients); + if ($iSent === 0) + { + // Beware: it seems that $aFailedRecipients sometimes contains the recipients that actually received the message !!! + IssueLog::Warning('Email sending failed: Some recipients were invalid, aFailedRecipients contains: '.implode(', ', $aFailedRecipients)); + $aIssues = array('Some recipients were invalid.'); + $oKPI->ComputeStats('Email Sent', 'Error received'); + return EMAIL_SEND_ERROR; + } + else + { + $aIssues = array(); + $oKPI->ComputeStats('Email Sent', 'Succeded'); + return EMAIL_SEND_OK; + } } - else + catch (Exception $e) { - $aIssues = array(); - return EMAIL_SEND_OK; + $oKPI->ComputeStats('Email Sent', 'Error received'); + throw $e; } }