2016-08-31 75 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/频繁。这是一个值得信赖的参考。

还有一些网络服务将以各种方式呈现电子邮件的图像。石蕊是一种常见的。我用它来生成并发送给工作中的客户的电子邮件。市场部也喜欢它。