Gmail API - Text Word Wrap

When sending emails using the Gmail API, it puts hard line breaks in the body with a length of about 78 characters per line. A similar question about this can be found here .

How can I make this stop? I just want to send clear text emails through the API without line breaks. The current formatting looks awful, especially on mobile clients (tested in Gmail and iOS Mail applications).

I tried the following headers:

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

Content-Transfer-Encoding: quoted-printable

Did I miss something?

EDIT: As suggested by Mr. Ribot, I also tried this with no luck:

Content-Type: mixed/alternative

EDIT 2: Here is the exact format of the message being sent (attempt with quoted-printableand without a 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.

Base64, POST /gmail/v1/users/{my_account}/drafts/send?fields=id JSON:

{
    "id": MSG_ID,
    "message": {
        "raw": BASE64_DATA
    }
}
+4
2

quoted printable encoder , API ?

Per wikipedia , = 76 , .

UPDATE

, (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.
+2

, , :

1. def create_message(sender, to, cc, subject, message_body):
2.     message = MIMEText(message_body, 'html')
3.     message['to'] = to
4.     message['from'] = sender
5.     message['subject'] = subject
6.     message['cc'] = cc
7.     return {'raw': base64.urlsafe_b64encode(message.as_string())}

, , , , , dict ( message), (line 2):

  • message = MIMEText(message_body, 'html') < - 'html' MIMEText

, Google gmail API, , , , . ... message = MIMEText(message_body)

python email.mime.text.MIMEText. MIMEText:

  • email.mime.text.MIMEText(_text [, _subtype [, _charset]]) _subtype. : 'html' _subtype.

, Google, Python mime.text.MIMEText

0

Source: https://habr.com/ru/post/1657946/


All Articles