Using SmtpJS in a userscript: Doesn't work, no error messages?

浪子不回头ぞ 提交于 2019-12-04 19:11:23

If you look at the smtpjs.com source, it creates a post request url, then appends it to the document inside of a <link>. This won't work on secure pages.

/* SmtpJS.com */
Email = {
  send: function (t, e, o, n, d, r, c) {
    var a = Math.floor(1e6 * Math.random() + 1),
     m = "http://smtpjs.com/smtp.aspx?";
     m += "From=" + t,
     m += "&to=" + e,
     m += "&Subject=" + encodeURIComponent(o),
     m += "&Body=" + encodeURIComponent(n),
     void 0 == d.token ?
       (m += "&Host=" + d, m += "&Username=" + r, m += "&Password=" + c, m += "&Action=Send") :
       (m += "&SecureToken=" + d.token, m += "&Action=SendFromStored"),
     m += "&cachebuster=" + a,
     Email.addScript(m) 
  },
  addScript: function (t) {
    var e = document.createElement("link");
    e.setAttribute("rel", "stylesheet"),
    e.setAttribute("type", "text/xml"),
    e.setAttribute("href", t),
    document.body.appendChild(e)
  }
};

You could use most of the above code... keep the send function, but replace the addScript function with a GM_xmlhttpRequest to post the data to their server.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!