为什么 GMail API 会从外发邮件中删除文档类型和注释?

Bra*_*gel 5 gmail-api

Gmail消息发送 API似乎正在从外发消息中删除文档类型和 HTML 注释。

再现

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

生成消息.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);
Run Code Online (Sandbox Code Playgroud)

实际结果

当我查看在 bradvogel@outlook.com 收到的电子邮件中的原始消息源时,它没有文档类型或注释:

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--
Run Code Online (Sandbox Code Playgroud)

预期结果

请注意下面的文档类型:

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--
Run Code Online (Sandbox Code Playgroud)

笔记

通过 SMTP 发送相同的消息会保留整个消息。

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

有谁知道如何在通过 Gmail 消息发送 api 发送的消息中保留文档类型和注释?