发送文本和 HTML 电子邮件 - 为什么 Gmail 总是选择文本版本?
我正在使用 ActionMailer.NET 从 ASP.NET MVC 应用程序发送一些电子邮件。
现在,此过程的一部分是发送消息的 HTML 和 文本版本,以支持纯文本客户端。
但我看到的是 GMail 总是选择文本版本。
我尝试了雅虎,雅虎正确选择了 HTML 版本。
我尝试将 HTML 简化为
和
标记,GMail 仍然选择文本版本,这意味着没有HTML 内容有问题。
这是预期的行为吗?
因为当我仅发送 HTML 版本时,GMail 将正确显示 HTML 版本。
我在 HTML 中设置了元标记,如下所示:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
有其他人遇到过这种行为并找到解决方案吗?
因为就目前情况而言,我可能必须仅发送 HTML 版本,以便 GMail 能够呈现它,因为我们有太多的客户使用 GMail。
这是我尝试发送的基本 HTML 的示例:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title></title>
</head>
<body>
<h1>This is the heading</h1>
<span>This is some text.</span>
</body>
</html>
GMail 甚至不允许这样做。
I'm sending some emails from my ASP.NET MVC application, using ActionMailer.NET.
Now, part of this process is sending both HTML and text versions of the message, to support text-only clients.
But what i'm seeing is that GMail is always picking the text version.
I tried Yahoo, and Yahoo is picking the HTML version correctly.
I tried dumbing down my HTML to nothing but a <h1>
and a <span>
tag, and GMail still picked the text version, which means there isn't a problem with the content of the HTML.
Is this expected behaviour?
Because when i send only the HTML version, GMail will show the HTML version correctly.
I've set the meta-tags in the HTML as follows:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
Has anyone else encountered this behaviour, and found a solution?
Because as it stands, i'll probably have to send only the HTML version, so that GMail will render it, as too many of our clients use GMail.
Here's an example of basic HTML i'm trying to send:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title></title>
</head>
<body>
<h1>This is the heading</h1>
<span>This is some text.</span>
</body>
</html>
And GMail won't even allow that.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
大多数基于 Web 的客户端和桌面电子邮件客户端都会忽略电子邮件的
标记中的任何内容。
要发送 html 和文本版本,您需要正确构造邮件消息 - 有两个 mime 块。
向我们展示您用于构建电子邮件的完整代码。
Most web-based clients and desktop email clients ignore anything in the
<head>
tag of an email.To send both html and text versions, you will need to construct the mail message properly - have two mime chunks.
Show us the full code you are using to construct your email.
我想我应该检查的第一件事是 ActionMailer.NET 问题。
我用谷歌搜索了一下,但没有出现。
这个问题已于 2 天前修复,因此获取最新的软件包可以解决该问题。
https://bitbucket.org/swaj/actionmailer.net/issue /23/multipart-mail-problem
这个问题实际上与 Thunderbird 有关,但猜测 GMail 也有类似的处理多部分电子邮件的方式。
问题解决了!
I guess the first thing i should have checked is the ActionMailer.NET issues.
I did some Googling, and it didn't come up.
This issue was fixed 2 days ago, so getting the latest package fixed the problem.
https://bitbucket.org/swaj/actionmailer.net/issue/23/multipart-mail-problem
That issue was actually relating to Thunderbird, but guess GMail has a similar way of handling multipart emails.
Problem solved!