2015-11-18 34 views
9

使用PHPMailer 5.2.14,電子郵件以text/html發送。即將發佈的文本每75個字符就會有相同的符號。PHPMailer插入'='等號每75個字符

我嘗試使用EOL workaround,但它並沒有刪除多餘的等號:在收到

$email = new PHPMailer(); 
$email->From  = '[email protected]'; 
$email->FromName = 'FromUser'; 
$email->AddAddress('[email protected]'); 
$email->Subject = 'This is a test'; 
$email->IsHTML(true); 
$email->Body = "<p>This is a test.&nbsp; This is a test.&nbsp; This is a test.&nbsp; This is a test.&nbsp; This is a test.&nbsp; This is a test.&nbsp; This is a test.&nbsp; This is a test.&nbsp; This is a test.&nbsp; This is a test.&nbsp; This is a test.&nbsp; This is a test.&nbsp; This is a test.&nbsp; This is a test.&nbsp; </p>"; 

// fix EOL here? 
$email->LE = PHP_EOL; 

$email->Send(); 

所得來源:在Outlook中查看時

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><font face="arial"><base href="http://example.com/"><!-- </base> -->= 
<p>This is a test.&nbsp; This is a test.&nbsp; This is a test.&nbsp; This i= 
s a test.&nbsp; This is a test.&nbsp; This is a test.&nbsp; This is a test.= 
&nbsp; This is a test.&nbsp; This is a test.&nbsp; This is a test.&nbsp; Th= 
is is a test.&nbsp; This is a test.&nbsp; This is a test.&nbsp; This is a t= 
est.&nbsp; This is a test.&nbsp; This is a test.&nbsp; This is a test.&nbsp;= 
</p></font> 

等號出現。當我發送相同的文本/ HTML到一個Gmail帳戶,等號不存在。

需要做什麼來消除使用Outlook的收件人的這些流浪等號?

+0

請降低你的文字的大小,我們並不需要這麼多的線路要明白,有'='。你用什麼代碼到文本編碼? –

+0

請建議適當子,如果問PHP的問題是不恰當的位置。 –

+0

再次爲個人投票關閉這個問題作爲題外話,請建議適當子,而不是默默地殺死的問題。我也建議不關閉這個標籤'PHPMailer'已被使用''2055''這個回覆。 –

回答

6

我在PHPMailer中遇到了與html-emails相同的問題。我測試過不同的東西,結果發現:

  • 的問題發生,如果該消息具有特殊的長度 - 在我的情況> 1002個字母在一行(當我已刪除了部分字母(無關緊要哪些)的電子郵件是正確的)
  • 該問題僅在某些電子郵件程序中可見(例如MS Outlook,網站t-online.de;沒有雅虎問題)
  • 我試用過PHPMailer 5.2.7 - 5.2.14:The PHPMailer> 5.2.10存在問題(PHPMailer 5.2.7 - 5.2.10沒有問題)
  • 解決方案如'$ mail-> Encoding =「7bit」;'或'$ mail-> LE = PHP_EOL;'沒有爲我工作
  • 通過isSmtp()發送電子郵件時沒有問題。
  • 在兩臺不同的服務器上測試:服務器1包含等號,服務器2不包含該標記但包含錯誤的linebreaks - 兩臺服務器上的php配置幾乎相同>似乎不是php問題

因此,對於我來說,解決方案是「採取PHPMailer 5.2。10" 直到他們解決了一個新版本的問題 - 沒有很好的解決方案,但它爲我工作,直到我找到一個更好的;-)

+0

5.2.10修復了這個問題。感謝你的回答。 –

+0

有沒有人試過5.2.16? – HWD

5

這裏是你的文件應該是什麼樣子:之外的

<!DOCTYPE html> 
<head> 
    meta stuff and <base href...> 
</head> 
    <body> 
    HTML stuff 
    </body> 
</html> 

任何事情,不符合HTML,將提出一個阻尼器上的一天。

據我所看到的,你有屬於在<head>,並有在<body>等等,等等屬於<font>標籤如果沒有適當的HTML文檔結構元,那麼事情會抱怨肯定。包含有效的文檔類型。

關於<font>標籤的快速旁註;它已被棄用。

您可以改爲使用內聯CSS樣式。不要使用<style>標籤,因爲大多數電子郵件客戶端都會拋出它並忽略它。

+0

我不知道爲什麼這被選爲正確的答案。雖然這是很好的建議,但與問題無關。 – Synchro

+2

@Synchro [閱讀OP的評論...](http://stackoverflow.com/questions/33787777/phpmailer-inserts-equal-sign-every-75th-character/33788388?noredirect=1#comment55343609_33787777)。它與它有關。也請看他們的代碼以及他們試圖發送的消息。 –

+0

弗雷德的答案是堅實的,但SusiMage的答案在下面(昨天發佈)現在被標記爲選定的答案。看他/她的帖子爲什麼。 –

2

這就是所謂的quoted-printable encoding,在電子郵件中很常見。等號用作轉義字符,並且行長度限制爲76個字符。如果Outlook沒有認識到這一點,您可能需要手動設置標題,告訴它它是以這種方式編碼的。

-1
$email = new PHPMailer(); 
$email->From  = '[email protected]'; 
$email->FromName = 'FromUser'; 
$email->AddAddress('[email protected]'); 
$email->Subject = 'This is a test'; 
$email->IsHTML(true); 
$email->Body = "<p>This is a test.&nbsp; This is a test.&nbsp; This is a test.&nbsp; This is a test.&nbsp; This is a test.&nbsp; This is a test.&nbsp; This is a test.&nbsp; This is a test.&nbsp; This is a test.&nbsp; This is a test.&nbsp; This is a test.&`enter code here`nbsp; This is a test.&nbsp; This is a test.&nbsp; This is a test.&nbsp; </p>"; 

// fix EOL here? 
$email->LE = PHP_EOL; 

$email->Send(); 
0

隨着'$mail->Encoding = 'base64';現在爲我們工作與v5.2.17 。但願這是最後固定在V6。