Problem: Whenever I send a plain text email using the official google api node package (googleapis), I get line breaks around sentences longer than around 70 characters.
var headersObj = {
"To": toEmail,
"Subject": subject,
"From": fromEmail,
"Content-Type": "text/plain; charset=UTF-8"
//"Content-Transfer-Encoding": "quoted-printable"
}
for(var header in headersObj) {
email += header += ": " + headersObj[header] + "\r\n";
}
email += "\r\n" + message;
gmail.users.messages.send({
userId: 'me',
auth: oauth2Client,
resource: {
raw: btoa(email).replace(/\+/g, '-').replace(/\//g, '_')
}
}, function (err, response) {
if(err) {
reject(err);
}else{
resolve(response);
}
});
I heard I needed to change "Content-Transfer-Encoding" but that only works on html emails. What about plain text emails? I've been searching for months for an answer. Any suggestions, ideas, or solutions?
Please notice any line longer than 70 characters automatically breaks. Why does this behavior happen and how to solve it?