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; } }