0

如果我使用"mailto:example@domain.com",它不会立即发送电子邮件,但它会带您自己发送(但它会为您自动填写)。

我想要的是当他们填写表格并单击提交按钮时,它将使用他们的电子邮件将测试电子邮件发送给我。

这是我的代码,

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, n, !0) : "undefined" != typeof XDomainRequest ? (t = new XDomainRequest).open(e, n) : t = null, t } };

Email.send({
    Host : "smtp.gmail.com",
    Username : "MY_USERNAME",
    Password : "MY_PASSWORD",
    To : 'example1@gmail.com',
    From : "example2@gmail.com",
    Subject : "The subject",
    Body : "The body"
    }).then(
      message => alert(message)
    );

但是该代码不起作用:(

4

0 回答 0