【问题标题】:Why does the GMail API strip the doctype and comments from outgoing messages?为什么 GMail API 会从外发邮件中去除文档类型和注释?
【发布时间】:2014-09-18 16:56:03
【问题描述】:

Gmail Message Send API 似乎正在从外发邮件中删除 doctype 和 HTML cmets。

复制

  1. 转到https://developers.google.com/gmail/api/v1/reference/users/messages/send
  2. 向下滚动到“试试看!”
  3. 使用 OAuth 登录
  4. 对于“userId”,输入:me
  5. 对于“原始”,输入以下节点脚本的结果:

generateMessage.js

var email = "From: 'me'\r\n" +
  "To: bradvogel@outlook.com\r\n" +
  "Subject: Test Doctype\r\n" +
  "Content-Type: text/html; charset=utf-8\r\n" +
  "\r\n" +
  "<!doctype html>" +
  "<html><body>test <!--[if !mso]>hidden from outlook<!--<![endif]--> </body></html>";

var base64 = new Buffer(email).toString('base64');
var websafeBase64 = base64.replace(/\//g, '_').replace(/\+/g, '-');
console.log(websafeBase64);

实际结果

当我从 bradvogel@outlook.com 收到的电子邮件中查看原始消息源时,它没有 doctype 或 cmets:

To: bradvogel@outlook.com
Subject: Test Doctype
Content-Type: multipart/alternative; boundary=089e0102fc52abed0a04ff355038

--089e0102fc52abed0a04ff355038
Content-Type: text/plain; charset=UTF-8

test

--089e0102fc52abed0a04ff355038
Content-Type: text/html; charset=UTF-8

<html><body>test  </body></html>

--089e0102fc52abed0a04ff355038--

预期结果

注意下面的文档类型:

To: bradvogel@outlook.com
Subject: Test Doctype
Content-Type: multipart/alternative; boundary=089e0102fc52abed0a04ff355038

--089e0102fc52abed0a04ff355038
Content-Type: text/plain; charset=UTF-8

test

--089e0102fc52abed0a04ff355038
Content-Type: text/html; charset=UTF-8

<!doctype html>
<html><body>test <!--[if !mso]>hidden from outlook<!--<![endif]--> </body></html>

--089e0102fc52abed0a04ff355038--

注意事项

通过 SMTP 发送同一封邮件会保留整个邮件。

需要 doctype 和 cmets 来格式化 Outlook 和 iOS Mail 的电子邮件。 API 似乎正在获取我的原始 rfc822 消息并将其转换为具有文本和 html 表示形式的多部分/替代,但删除了重要内容。

有谁知道如何在通过 Gmail Message Send api 发送的消息中保留 doctype 和 cmets?

【问题讨论】:

  • 为 Brad 的问题添加更多细节:HTML 电子邮件中没有 doctype,导致 iOS 邮件以“几乎标准”模式显示电子邮件,类似于“怪癖模式”呈现在旧的 IE 浏览器中。我能找到触发“标准”模式的唯一方法是包含一个doctype,当通过 Gmail API 发送电子邮件时,它被奇怪地去掉了。
  • 在这种情况下gmailclient 是什么?能够在本地运行会有所帮助。
  • Logan,更新了重现步骤,使其更加清晰。谢谢;)。
  • 我联系了工程团队,以了解有关此行为是否为故意的更多信息。
  • @BradVogel 嗨,您能发布发送电子邮件的代码吗?我遇到了与您有关的问题,我想看看您是如何发送的。提前谢谢!

标签: gmail-api


【解决方案1】:

这可能只是一个 API 设计决定。在他们的问题跟踪器中归档为https://code.google.com/a/google.com/p/apps-api-issues/issues/detail?id=3786&thanks=3786&ts=1427478929

【讨论】:

    猜你喜欢
    • 2013-03-25
    • 1970-01-01
    • 2016-05-12
    • 2021-09-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-09
    • 1970-01-01
    相关资源
    最近更新 更多