如何解决如何使用Javasctipt在SMTP中发送html电子邮件以及将其放入正文中
您好,所以我一直尝试使用网站发送电子邮件,或将电子邮件确认为注册等。因此,我在这里的测试确实发送了电子邮件,并接受了h3标签,但是没有什么更复杂的了,有什么办法可以使我做到这一点发送更多的HTML和CSS和可能的JavaScript的电子邮件?我可以在“正文”中链接file.html使其更容易吗?
代码如下:
//index.js
/* SmtpJS.com - v3.0.0 */
var Email = {
send: function (a) {
return new Promise(function (n,e) {
(a.nocache = Math.floor(1e6 * Math.random() + 1)),(a.Action = "Send");
var t = JSON.stringify(a);
Email.ajaxPost("https://smtpjs.com/v3/smtpjs.aspx?",t,function (e) {
n(e);
});
});
},ajaxPost: function (e,n,t) {
var a = Email.createCORSRequest("POST",e);
a.setRequestHeader("Content-type","application/x-www-form-urlencoded"),(a.onload = function () {
var e = a.responseText;
null != t && t(e);
}),a.send(n);
},ajax: function (e,n) {
var t = Email.createCORSRequest("GET",e);
(t.onload = function () {
var e = t.responseText;
null != n && n(e);
}),t.send();
},createCORSRequest: function (e,n) {
var t = new XMLHttpRequest();
return (
"withCredentials" in t
? t.open(e,!0)
: "undefined" != typeof XDomainRequest
? (t = new XDomainRequest()).open(e,n)
: (t = null),t
);
},};
function sendEmail() {
Email.send({
Host: "smtp.gmail.com",Username: "email to send from",Password: "password",To: "my email for the test",From: "email to send from",Subject: "hai",Body: "i can put normal text here or h3 tags,but i am trying to make it work with more complex html aka adding css too,and if possible just link an html file here so i dont type everything here",}).then((message) => alert("mail sent successfully"));
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。