Gmail API - plaintext word wrapping

email, gmail, gmail-api

Solution

Are you running the content through a quoted printable encoder and sending the encoded content value along with the header or expecting the API to encode it for you?

Per wikipedia it seems like if you add soft line breaks with `=` less than 76 characters apart as the last character on arbitrary lines, they should get decoded out of the result restoring your original text.

UPDATE

Try sending with this content whose message has been quoted-printable encoded (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.

Problem

When sending emails using the Gmail API, it places hard line breaks in the body at around 78 characters per line. A similar question about this can be found here. How can I make this stop? I simply want to send plaintext emails through the API without line breaks. The current formatting looks terrible, especially on mobile clients (tested on Gmail and iOS Mail apps). I've tried the following headers: `Content-Type: text/plain; charset=UTF-8` `Content-Transfer-Encoding: quoted-printable` Am I missing anything? EDIT: As per Mr.Rebot's suggestion, I've also tried this with no luck: `Content-Type: mixed/alternative` EDIT 2: Here's the exact format of the message I'm sending (attempted with and without the `quoted-printable` header: ``` 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. ``` I take this full message and Base64-encode it, then POST it to `/gmail/v1/users/{my_account}/drafts/send?fields=id` with the following JSON body: ``` { "id": MSG_ID, "message": { "raw": BASE64_DATA } } ```

Original source

Related problems