浏览代码

Enhancement of the Email class to preserve backward compatibility...

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@2141 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 13 年之前
父节点
当前提交
f36126299c
共有 1 个文件被更改,包括 21 次插入1 次删除
  1. 21 1
      core/email.class.inc.php

+ 21 - 1
core/email.class.inc.php

@@ -138,7 +138,27 @@ class EMail
 		if (strlen($sValue) > 0)
 		{
 			$oHeaders = $this->m_oMessage->getHeaders();
-			$oHeaders->addTextHeader($sKey, $sValue);
+			switch(strtolower($sKey))
+			{
+				case 'from':
+				case 'cc':
+				case 'bcc':
+				$aMatches = array();
+				// Header may be in the form: John Doe <jd@company.com>
+				if (preg_match('/^([^<]+) <([^>]+)>$/', $sValue, $aMatches))
+				{
+					$aHeader = array($aMatches[2] => $aMatches[1]);
+				}
+				else
+				{
+					$aHeader = array($sValue);
+				}
+				$oHeaders->addMailboxHeader($sKey, $aHeader);
+				break;
+
+				default:
+				$oHeaders->addTextHeader($sKey, $sValue);
+			}
 		}
 	}