I'm trying to send an email using the gmail rest api, everything works fine except if I try to use special characters in the subject. I've tried different solutions that I've found around like:
`Subject: =?utf-8?B?${email.subject.toString('base64')}?=\n\n` +
`Subject: =?iso-8859-1?Q? ${quotedPrintable.encode(utf8.encode(email.subject))}?=\n\n` +
result from example 2
This is the actual code:
const mail = Buffer.from(`From: ${from}\n` +
'Content-Type: text/html; charset=UTF-8\n' +
`To: ${to}\n` +
`Cc: ${cc}\n` +
`Bcc: ${bcc}\n` +
`Subject: =?utf-8?B?${email.subject.toString('base64')}?=\n\n` +
`${$.html()}`)
.toString('base64').replace(/\+/g, '-').replace(/\//g, '_');
const response = await axios.post(`https://www.googleapis.com/gmail/v1/users/${from}/messages/send?access_token=${token}`, {
raw: mail,
});
This is a sample of the subject I want to send:
1 - = live unbound!! que viva España