admin管理员组文章数量:1417426
For some reason the Gmail API won't send an html email. Sending plaintext works fine:
var message = 'From: Me <[email protected]>\r\n' +
'To: Me <[email protected]>\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:
var message = 'From: Me <[email protected]>\r\n' +
'To: Me <[email protected]>\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 pliant?
For some reason the Gmail API won't send an html email. Sending plaintext works fine:
var message = 'From: Me <[email protected]>\r\n' +
'To: Me <[email protected]>\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:
var message = 'From: Me <[email protected]>\r\n' +
'To: Me <[email protected]>\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 pliant?
Share Improve this question asked Nov 6, 2014 at 0:50 robsrobs 571 silver badge4 bronze badges 5- How do you send mails using JavaScript? – Yang Commented Nov 6, 2014 at 1:11
- I'm using javascript to send a post request to the Gmail API where the raw variable is the parameter in the request. Sorry, I realize I didn't really provide any context in the question. – robs Commented Nov 6, 2014 at 1:30
- How are you creating rfc2822 string, message variable in the above example. I sit hard coded or Is there any other ways to that? @rob – Sasikanth Commented Mar 25, 2015 at 1:59
- @robs, Are inline styles working for your? – user555 Commented Mar 26, 2015 at 7:09
- Can I please see your full code? I have this exact same problem right now! – Penjimon Commented May 5, 2016 at 14:08
1 Answer
Reset to default 4For starters you need to use base64url encoding, using the web/url safe alphabet not just the standard btoa() base64. 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?)
本文标签: javascriptSend an HTML email using the Gmail APIStack Overflow
版权声明:本文标题:javascript - Send an HTML email using the Gmail API - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745264030a2650487.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论