[英]Send an HTML email using the Gmail API
For some reason the Gmail API won't send an html email. 由于某些原因,Gmail API无法发送html电子邮件。 Sending plaintext works fine: 发送纯文本可以正常工作:
var message = 'From: Me <me@gmail.com>\r\n' +
'To: Me <me@gmail.com>\r\n' +
'Subject: Hello\r\n\r\n'
'World'
var raw = btoa(message)
Then when I try html, it just shows up as an empty message: 然后,当我尝试html时,它只是显示为空消息:
var message = 'From: Me <me@gmail.com>\r\n' +
'To: Me <me@gmail.com>\r\n' +
'Subject: Hello\r\n'
'Content-Type: text/html; charset=utf-8\r\n' +
'Content-Transfer-Encoding: quoted-printable\r\n\r\n' +
'<html><body>' +
'<h1>World</h1>' +
'</body></html>'
var raw = btoa(message)
Any ideas? 有任何想法吗? Maybe because it's not RFC 2822 compliant? 也许是因为它不符合RFC 2822?
For starters you need to use base64url encoding, using the web/url safe alphabet not just the standard btoa() base64. 对于初学者,您需要使用base64url编码,不仅要使用标准的btoa()base64,还要使用Web / URL安全字母。 If that doesn't fix it can you post your code and the exact error message you're getting? 如果仍不能解决问题,您可以发布代码以及收到的确切错误消息吗? (Or does it work and not show up as html?) (或者它能正常工作并且不能显示为html吗?)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.