2016-08-31 76 views
1

我使用PHP Mailer發送HTML郵件。但是,當我發送電子郵件下面的所有填充,邊距,div大小等消失(在Outlook中)。如果我看看我的Gmail帳戶,它看起來很好。在iPhone的郵件應用程序邊緣等也沒有了。通過phpmailer發送html

<div id="wrapper" style="width: 100%;"> 
<table width=600 style="margin:0 auto"> 
<tbody> 
<tr> 
<td> 
<div id="Banner" style=" 
    max-width: 640px; 
    margin: 0 auto; 
    min-height: 60px; 
    background-color: #75dcfc; 
    width: 100%; 
"> 
<div class="center" style="margin: auto;text-align: center;"> 
    <img src="logourl" alt="test" style="max-width: 450px;padding-top: 0px;width: 50%;"> 
    </div> 
    </div> 

<div id="box" style="max-width: 640px;width: 100%;background-color: white;color: #696969;border-style: solid;border-width: 0px;text-align: center;border-color: #d3d3d3;margin-left: auto;margin-right: auto;overflow: hidden;padding: 0px;border-style: solid;height: 500px"> 
<div id="personalmsg" style="width: 100%;text-align: center;font-size: 22px;margin-left: auto;margin-right: auto;max-width: 400px;padding: 0px;"> 
    <p style="text-align: left;font-size: 17px;margin-top: 50px; color: #000;font-weight: normal;font-style: normal;">hello</p> 


</div> 

</div> 
    <h2 id="link" style="text-align: center;max-width: 640px;margin: 0 auto;background-color: #75dcfc;padding-top: 15px;padding-bottom: 15px;width: 100%;"><a href="website" style="color: #fff;text-decoration: none;">Visit us</a></h2> 
</td> 
</tr> 
</tbody> 
</table> 
</div> 

正如你所看到的我只使用內嵌的CSS。但是我沒有得到我做錯了什麼。也許它有助於顯示我如何發送電子郵件:

$mail = new PHPMailer; 

$mail->setFrom('[email protected]'); 
$mail->addAddress($email); 

$mail->Subject = "Your Email"; 
$mail->Body = $html; 
$mail->isHTML(true); 
try { 
    $mail->Send(); 
} 
catch (Exception $e) { 

} 

雖然$ html是將HTML保存爲字符串。

我很感謝在正確的方向

+0

確保您使用完整的HTML標記。在這裏並不是這種情況,至少不是你發佈的內容。和/或它可能是您的Outlook的本地問題。 –

回答

0

的Outlook是臭名昭著的不支持CSS以及任何欣。所有的電子郵件客戶端都有他們自己的怪癖HTML和CSS,這是很多的試驗和錯誤。

我無法回答你的問題,但我可以爲你提供這些引用來重新編碼你的html。

Microsoft爲outlook提供html/css指南。

https://msdn.microsoft.com/en-us/library/aa338201.aspx#Word2007MailHTMLandCSS_Full

我用https://www.campaignmonitor.com/css/頻繁。這是一個值得信賴的參考。

還有一些網絡服務將以各種方式呈現電子郵件的圖像。石蕊是一種常見的。我用它來生成併發送給工作中的客戶的電子郵件。市場部也喜歡它。