我正在尝试使用gmail rest api发送电子邮件,除非我尝试在主题中使用特殊字符,否则一切正常。我尝试了各种不同的解决方案,例如:
`Subject: =?utf-8?B?${email.subject.toString('base64')}?=\n\n` +
`Subject: =?iso-8859-1?Q? ${quotedPrintable.encode(utf8.encode(email.subject))}?=\n\n` +
示例2的结果
这是实际的代码:
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,});
这是我要发送的主题的一个示例:
1 - = live unbound!! ? ? que viva España