使用Gmail API发送电子邮件时,它会在正文中放置大约78个字符的强制换行符.关于这一点的类似问题可以在
here找到.
我怎么能停下来?我只是想通过API发送纯文本电子邮件而不会有换行符.目前的格式看起来很糟糕,尤其是在移动客户端上(在Gmail和iOS Mail应用上测试).
我试过以下标题:
内容类型:text / plain;字符集= UTF-8
Content-Transfer-Encoding:quoted-printable
我错过了什么吗?
编辑:根据Mr.Rebot的建议,我也试过这个没有运气:
内容类型:混合/替代
编辑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.
我将完整的消息和Base64编码,然后使用以下JSON正文将其POST到/ gmail / v1 / users / {my_account} / drafts / send?fields = id:
{
"id": MSG_ID,
"message": {
"raw": BASE64_DATA
}
}
最佳答案 您是通过
quoted printable编码器运行内容并将编码的内容值与标题一起发送还是期望API为您编码?
根据wikipedia,似乎如果添加=少于76个字符的软换行符作为任意行上的最后一个字符,它们应该从恢复原始文本的结果中解码出来.
UPDATE
尝试使用此内容进行发送,其内容的消息已被引用 – 可打印编码(base64 it):
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.