前端怎么实现发送邮件啊

前端怎么实现发送邮件啊,有没有案例啊,谢谢

阅读 12.2k
9 个回答

应该有那种发送邮件的api接口的,在前台直接一个接口就ok,网上你找一下肯定有。就类似一个url可以发送短信一样:http://domain/sendsms?phone=1...

<a href="mailto:xxx@qq.com">发送邮件给我</a>

点击这个会调用本地的邮件客户端,没有客户端就不行了。

纯前端无法实现。

应该是前端告诉后台,让后台去发送

恐怕还真不行,只能通过后台去发送吧

新手上路,请多包涵

用node.js

如果是项目中需要,肯定要后端去发送的

mailto

  1. Smtp.js, http://www.smtpjs.com/,https://smtpjs.com/v3/smtp.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, n, !0) : "undefined" != typeof XDomainRequest ? (t = new XDomainRequest).open(e, n) : t = null, t
        }
    };
  2. https://formspree.io/ 有商业解决方案,但是免费版一个月只有五十封。
推荐问题