简体   繁体   English

如何通过带有angularjs的Mailgun发送电子邮件?

[英]How to send an email via Mailgun with angularjs?

I'm trying to send via mailgun API in angularjs but it's not working here is my code snippet: 我正在尝试通过angularjs中的mailgun API发送,但它在这里不起作用是我的代码片段:

console.log('step1');

    var mailgunUrl = "DOMAIN_NAME";
    var mailgunApiKey = window.btoa("api:key-API_KEY")

    $scope.send = function () {
        console.log('in here');
        $http({
            "method": "POST",
            "url": "https://api.mailgun.net/v3/" + mailgunUrl + "/messages",
            "headers": {
                "Content-Type": "application/x-www-form-urlencoded",
                "Authorization": "Basic " + mailgunApiKey
            },
            data: "from=" + "test@example.com" + "&to=" + "TO_EMAIL_ADDRESS" + "&subject=" + "MailgunTest" + "&text=" + "EmailBody"
        }).then(function (success) {
            console.log("SUCCESS " + JSON.stringify(success));
        }, function (error) {
            console.log("ERROR " + JSON.stringify(error));
        });
    }

    console.log('step last');

it console "step1" and "step last" but its not sending mail. 它控制台“step1”和“step last”但它不发送邮件。

Can you please help me out or suggest what I can do here. 你能帮帮我或建议我能做些什么。

Thanks 谢谢

您是否添加了元标记:

<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM