Explorar o código

Fixed a regression introduced by [r3242] (warning when sending an email with an empty "To")

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@3265 a333f486-631f-4898-b8df-5754b55c2be0
dflaven %!s(int64=11) %!d(string=hai) anos
pai
achega
70412bb194

+ 6 - 3
core/email.class.inc.php

@@ -184,10 +184,13 @@ class EMail
 
 		$oMailer = Swift_Mailer::newInstance($oTransport);
 
-		$iSent = $oMailer->send($this->m_oMessage);
+		$aFailedRecipients = array();
+		$iSent = $oMailer->send($this->m_oMessage, $aFailedRecipients);
 		if ($iSent === 0)
 		{
-			$aIssues = array('No valid recipient for this message.');
+			// 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;
 		}
 		else
@@ -321,7 +324,7 @@ class EMail
 	public function GetRecipientTO($bAsString = false)
 	{
 		$aRes = $this->m_oMessage->getTo();
-		if ($aRes === false)
+		if ($aRes === null)
 		{
 			// There is no "To" header field
 			$aRes = array();

+ 1 - 1
lib/swiftmailer/lib/classes/Swift/Mime/SimpleMimeEntity.php

@@ -595,7 +595,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
         if ($this->_headers->has($field)) {
             return $this->_headers->get($field)->getFieldBodyModel();
         }
-        return false;
+        return null; // Returning null is equivalent to no return, but is easier to read!!
     }
 
     /**