HTML格式的电子邮件根本不在Gmail中显示,但在其他邮件客户端中

jos*_*lat 43 css gmail html-email gmail-imap

我目前正在从PHP的mail()函数发送html格式的电子邮件,并检查它们只是为了确保它们显示为HTML(格式化一边,我很清楚格式将从客户端到客户端变化(可能很大)) .它们在Apple Mail客户端以及我的iPhone上显示为HTML.但是,Gmail只是拒绝将其显示为HTML.并且我并不是说它的格式不正确,它只是不使用它出现的HTML.

奇怪的是,正在加载来自标签的img,但是就是这样......是不是我主要使用div进行布局,这对于Gmail或其他东西来说太新了(vs表)?

至于CSS以及什么不是,查看原始源显示以下内容:

<html><head><style>body { background-color: #F2F2F2; font-family: Arial; color: #5C5C5C; font-size: 11pt; } a { color: #46AAFF; text-decoration: none; } #container { width: 750px; margin-right: auto; margin-left: auto; } #header { float: right; padding: 3px; height: 30px; } #header a { color: #666666; margin-right: 10px; } #mainBody { padding: 20px; background-color: #FFF; border: 1px solid #DADADA; border-radius: 3px; } #imageArea { border-top: solid #E8E8E8 1px; margin: 15px; } #singleImageArea { width: 250px; padding: 15px; } #singleImageArea p { float: right; line-height: 30px; width: 130px; margin-top: 20px; } #footer { padding: 10px; color: gray; } #footer p { text-shadow: 0px 2px #FFF; font-size: 10pt; } #footer a { color: #ADADAD; float: right; padding-left: 20px; padding-right: 20px; } #footer img { width: 35px; height: 23px; padding: 10px; float: left; } </style></head><body><div id="container"><div id="header"><a href="http://appname.local/login/">Login</a></d
 iv><div style="clear: both;"></div><div id="mainBody"><h1>Hi Josh Holat!</h1>You've sent a request to <strong>reset</strong> your appname password. Just click the link below <em>(or copy and paste it into your browser)</em> and follow the instructions to set a new password. The link will expire in one hour.<br/><br/><a href="http://appname.local/sb/reset-password/?r=2768af61698fcde9c04f9449351575d6bfe6d720">http://appname.local/sb/reset-password/?r=2768af61698fcde9c04f9449351575d6bfe6d720</a><br/><br/>If you feel this request was submitted in error, don't worry; you can safely ignore this e-mail and your password will not be changed.<br/><br/>Much Love,<br/>Us</div><!-- #mainBody --><div id="footer"><img src="http://appname.local/images/email/footer_sb.png" /><p>&copy; 2011 appname, Inc. All Rights Reserved <a href="http://appname.local/sb/legal/">Legal</a><a href="http://appname.local/sb/contact/">Contact</a><a href="http://s
 tagebloc.local/sb/developers/">Developers</a><a href="http://appname.local/sb/blog/">Blog</a></p></div><!-- #footer --></div><!-- #container --></body></html>
Run Code Online (Sandbox Code Playgroud)

以及:

    Delivered-To: appname@gmail.com
Received: by 10.229.40.2 with SMTP id i2cs133298qce;
        Sun, 28 Aug 2011 14:29:08 -0700 (PDT)
Received: by 10.42.152.199 with SMTP id j7mr4419937icw.417.1314566947950;
        Sun, 28 Aug 2011 14:29:07 -0700 (PDT)
Return-Path: <_www@joshholat.local>
Received: from joshholat.local (arh2281.urh.uiuc.edu [130.126.70.193])
        by mx.google.com with ESMTP id w3si6800550icz.109.2011.08.28.14.29.06;
        Sun, 28 Aug 2011 14:29:06 -0700 (PDT)
Received-SPF: neutral (google.com: 130.126.70.193 is neither permitted nor denied by best guess record for domain of _www@joshholat.local) client-ip=130.126.70.193;
Authentication-Results: mx.google.com; spf=neutral (google.com: 130.126.70.193 is neither permitted nor denied by best guess record for domain of _www@joshholat.local) smtp.mail=_www@joshholat.local
Received: by joshholat.local (Postfix, from userid 70)
    id 775063662E01; Sun, 28 Aug 2011 16:29:06 -0500 (CDT)
To: Josh Holat <appname@gmail.com>
Subject: Password Reset Request
X-PHP-Originating-Script: 501:Email.php
From: appname <noreply@appname.com>
Content-type: text/html
Message-Id: <20110828212906.775063662E01@joshholat.local>
Date: Sun, 28 Aug 2011 16:29:06 -0500 (CDT)
Run Code Online (Sandbox Code Playgroud)

我很困惑为什么第三方客户会表现得很好但Gmail只是忽略它?

Bro*_*omb 75

Gmail不支持该<style>标记.您需要使用内联css使gmail正常工作.

这是一个参考列表. http://www.campaignmonitor.com/css/

  • 真?哇.那真是太糟糕了......谢谢你的链接. (14认同)
  • 哇,很高兴看到来自Gmail的这种糟糕的支持,这是最受欢迎的电子邮件服务之一!Apple邮件和Android 4(Gmail)似乎领先于支持.我对Gmail感到很惊讶! (7认同)
  • @Solvitieg 上面的链接仍然与电子邮件客户端相关并且是最新的。是的,这仍然是 5 年前电子邮件客户端的相同问题。 (2认同)

Hen*_*jie 31

GMail 不支持 <style>标签,也不支持许多客户端.为了让您的生活更轻松,您可以使用convert将样式标记转换为内联CSS:http://beaker.mailchimp.com/inline-css


Abh*_*kar 5

上面的答案已经很好了,只是想补充几点。所有积分均归此链接

  1. Gmail 仅<style>支持<head>. Gmail 确实支持嵌入样式 ( <style>)。但是,嵌入样式仅在 HTML 文档的头部受支持。Gmail Android 和 iOS 应用程序<style>根本不支持渲染通过非 Google 帐户 (GANGA) 检索到的电子邮件。

  2. <style>如果 Gmail 遇到错误,它会删除您的整个阻止。

  3. Gmail 不允许负 CSS 边距值。

  4. Gmail 不支持属性选择器和大多数伪类。例如div[class="content"]{ color: red }。Gmail 也不支持伪类,如:checked:active

编辑:三年后回想起来,Gmail CSS 相当奇怪。