2017-03-09 67 views
0

我正在使用Amazon AWS SES。这是我如何发送电子邮件:以HTML代码形式发送的HTML电子邮件

$request = array(); 
    $request['Source'] = $row['emailfromname'] . " <{$verifyemail[0]}>"; 
    $request['Destination']['ToAddresses'] = $to; 
    $request['Message']['Subject']['Data'] = $row['emailsubject']; 
    $request['Message']['Body']['Html']['Data'] = $row['emailbody']; 

    try { 
     $result = $client->sendEmail($request); 
     $messageId = $result->get('MessageId'); 
    ... 

所以这是非常基本的。

我的问题是有些电子邮件是以HTML格式发送的。这里是一个犯罪者的例子:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> 
    <html><body><p><span style="font-family: Calibri, sans-serif; line-height: 11pt; font-size: 11pt; color: #333333;">Hi Name,</span></p> 
    <hr><span style="font-size:11pt;font-family:'Calibri',sans-serif"><b>From:</b> [email protected]<br><b>Sent:</b> Thursday, 9 March 2017 10:51 AM<br><b>To:</b> [email protected]<br><b>Subject:</b> Enquiry for ID: 98419081886, 123 Fake Street, 
    Docklands, Vic 3008, Listing Agent Leasing Consultant</span><br><br><div id="message" style="width: 600px; margin: 0 auto;"> 

     <h1 class="header"> 
      <img src="http://www.test.com/logo.png" style="border: 0; width: 258px;"><div class="header-separator" style="height: 4px; background-color: #e4002b; width: 100%; margin-top: 17px;"></div> 
     </h1> 





     <p style="margin: 0;">You have received a new enquiry for</p> 
     <br><p style="margin: 0;"> id: 98419081886</p> 

     <div class="footer" style="margin-top: 1em; padding: 5px; background: #999999; color: #fff;"> 
    Message sent from <a href="http://www.test.com.au" style="color: #fff;">www.test.com.au</a> </div> 

    </div></body></html> 

它发送纯文本为HTML代码与怪异的头信息。这是我的Outlook 2010电子邮件收到:

Docklands, Vic 3008, Listing Agent Leasing Consultant 
MIME-Version: 1.0 
Content-Type: text/html; charset=UTF-8 
Content-Transfer-Encoding: 7bit 

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> 
<html><body><p><span style="font-family: Calibri, sans-serif; line-height: 11pt; font-size: 11pt; color: #333333;">Hi Name,</span></p> <hr><span style="font-size:11pt;font-family:'Calibri',sans-serif"><b>From:</b> [email protected]<br><b>Sent:</b> Thursday, 9 March 2017 10:51 AM<br><b>To:</b> [email protected]<br><b>Subject:</b> Enquiry for ID: 98419081886, 123 Fake Street, Docklands, Vic 3008, Listing Agent Leasing Consultant</span><br><br><div id="message" style="width: 600px; margin: 0 auto;"> 

    <h1 class="header"> 
     <img src="http://www.test.com/logo.png" style="border: 0; width: 258px;"><div class="header-separator" style="height: 4px; background-color: #e4002b; width: 100%; margin-top: 17px;"></div> 
    </h1> 





    <p style="margin: 0;">You have received a new enquiry for</p> 
    <br><p style="margin: 0;"> id: 98419081886</p> 

    <div class="footer" style="margin-top: 1em; padding: 5px; background: #999999; color: #fff;"> 
Message sent from <a href="http://www.test.com.au" style="color: #fff;">www.test.com.au</a> </div> 

</div></body></html> 

这真的让我感到困惑的事情,但是,是其它非常相似的电子邮件,其中包含完全没有问题送!

我猜有在一个线索输出的第一行显示Docklands, VIC 3008 ...但是即使我删除断行,空格和逗号(,所以它读取123 Fake StreetDocklands),输出剧照与Docklands...包括启动在开始的空间!

回答

1

感到羞怯和懊恼......在领导我自己一场疯狂的追逐之后,我发现我的问题。这是微不足道的,我想删除这个问题,但我不希望它帮助其他SES用户。

我的主题里有一个换行符!

我不确定亚马逊如何或为什么会导致电子邮件正文出现问题,但确实如此。

相关问题