2015-11-18 31 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。