Gmail API-纯文本自动换行

hun*_*ley 6 email gmail gmail-api

使用Gmail API发送电子邮件时,它会在正文中设置硬行换行符,每行大约78个字符。与此类似的问题可以在这里找到。

我该如何停止?我只是想通过API发送纯文本电子邮件而没有换行符。当前的格式看起来很糟糕,尤其是在移动客户端上(在Gmail和iOS Mail应用程序上经过测试)。

我尝试了以下标题:

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

Content-Transfer-Encoding: quoted-printable

我有什么想念的吗?

编辑:根据Rebot先生的建议,我也没有运气尝试过此方法:

Content-Type: mixed/alternative

编辑2:这是我发送的消息的确切格式(尝试使用和不使用quoted-printable标题:

From: Example Account <example1@example.com>
To: <example2@example.com>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Subject: This is a test!
Date: Tue, 18 Oct 2016 10:46:57 -GMT-07:00

Here is a long test message that will probably cause some words to wrap in strange places.
Run Code Online (Sandbox Code Playgroud)

我将收到完整的消息并对其进行Base64编码,然后/gmail/v1/users/{my_account}/drafts/send?fields=id使用以下JSON正文将其发布到:

{
    "id": MSG_ID,
    "message": {
        "raw": BASE64_DATA
    }
}
Run Code Online (Sandbox Code Playgroud)

cch*_*ain 4

您是否通过引用的可打印编码器运行内容并将编码内容值与标头一起发送,或者期望 API 为您编码?

根据维基百科,如果您添加间隔少于 76 个字符的软换行符=作为任意行的最后一个字符,它们应该从恢复原始文本的结果中解码出来。

更新

尝试使用已引用可打印编码(base64)的消息内容发送:

From: Example Account <example1@example.com>
To: <example2@example.com>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Subject: This is a test!
Date: Tue, 18 Oct 2016 10:46:57 -GMT-07:00

Here is a long test message that will probably cause some words to wrap in =
strange places.
Run Code Online (Sandbox Code Playgroud)