Browse Source

Fixed regressions due to the integration of SwiftMailer

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@1639 a333f486-631f-4898-b8df-5754b55c2be0
romainq 13 năm trước cách đây
mục cha
commit
cd7cc6df75
2 tập tin đã thay đổi với 10 bổ sung5 xóa
  1. 5 5
      core/action.class.inc.php
  2. 5 0
      core/email.class.inc.php

+ 5 - 5
core/action.class.inc.php

@@ -275,7 +275,6 @@ class ActionEmail extends ActionNotification
 	protected function _DoExecute($oTrigger, $aContextArgs, &$oLog)
 	{
 		$sPreviousUrlMaker = ApplicationContext::SetUrlMakerClass();
-		$aHeaders = array();
 		try
 		{
 			$this->m_iRecipients = 0;
@@ -295,9 +294,8 @@ class ActionEmail extends ActionNotification
 			$sBody = MetaModel::ApplyParams($this->Get('body'), $aContextArgs);
 			
 			$oObj = $aContextArgs['this->object()'];
-			$sMessageId = sprintf('<iTop_%s_%d_%f@%s.openitop.org>', get_class($oObj), $oObj->GetKey(), microtime(true /* get as float*/), MetaModel::GetConfig()->Get('session_name'));
-			$sReference = $sMessageId;
-			$aHeaders['Message-ID'] = $sMessageId;
+			$sMessageId = sprintf('iTop_%s_%d_%f@%s.openitop.org', get_class($oObj), $oObj->GetKey(), microtime(true /* get as float*/), MetaModel::GetConfig()->Get('session_name'));
+			$sReference = '<'.$sMessageId.'>';
 		}
 		catch(Exception $e)
 		{
@@ -318,7 +316,7 @@ class ActionEmail extends ActionNotification
 			if (isset($sBody))     $oLog->Set('body', $sBody);
 		}
 
-		$oEmail = new EMail('', '', '', $aHeaders);
+		$oEmail = new EMail();
 
 		if ($this->IsBeingTested())
 		{
@@ -341,6 +339,7 @@ class ActionEmail extends ActionNotification
 			$oEmail->SetRecipientTO($this->Get('test_recipient'));
 			$oEmail->SetRecipientFrom($this->Get('test_recipient'));
 			$oEmail->SetReferences($sReference);
+			$oEmail->SetMessageId($sMessageId);
 		}
 		else
 		{
@@ -352,6 +351,7 @@ class ActionEmail extends ActionNotification
 			$oEmail->SetRecipientFrom($sFrom);
 			$oEmail->SetRecipientReplyTo($sReplyTo);
 			$oEmail->SetReferences($sReference);
+			$oEmail->SetMessageId($sMessageId);
 		}
 
 		if (empty($this->m_aMailErrors))

+ 5 - 0
core/email.class.inc.php

@@ -163,6 +163,11 @@ class EMail
 		$this->m_oMessage->addPart($sText, $sMimeType);
 	}
 
+	public function AddAttachment($data, $sFileName, $sMimeType)
+	{
+		$this->m_oMessage->attach(Swift_Attachment::newInstance($data, $sFileName, $sMimeType));
+	}
+
 	public function SetSubject($aSubject)
 	{
 		$this->m_oMessage->setSubject($aSubject);