使用angularjs中的mailgun发送电子邮件

时间:2017-03-11 05:52:38

标签: angularjs mailgun

我想用mailgun api发送邮件(1.5.8版) 代码如下:

3
6
6
10
13
5

但我收到了请求错误:

    var mailgunUrl = "sandbox459d327de2c64c7ab972c130a9747e87.mailgun.org";
    var mailgunApiKey = window.btoa("api:key-a34dcbe00b80094eae7a0cba9d5fc040");

    var requestHeaders = {
        'Authorization': "Basic " + mailgunApiKey,
        'Content-Type': "application/json",
        "Access-Control-Allow-Origin": "*",
        "Access-Control-Allow-Headers": "Content-Type, x-requested-with",
        "Access-Control-Allow-Methods":"GET, POST, PUT, DELETE, OPTIONS"
    }

    $http({
        method: 'POST',
        url: "https://api.mailgun.net/v3/" + mailgunUrl + "/messages",
        data: JSON.stringify({from:'postmaster@sandbox459d327de2c64c7ab972c130a9747e87.mailgun.org',to:'sh.omidrashidi@gmail.com',subject:'test of pstar',text:'OK'}),
        headers: requestHeaders
    });

我成功发送邮件与邮递员,但$ http angular get错误 如何解决问题?

0 个答案:

没有答案