Send email with Mailgun in angular

自古美人都是妖i 提交于 2020-01-06 15:25:08

问题


This is my code:

function sendEmail(){
    return $http.post('https://api:<MY SECRET API KEY>@api.mailgun.net/v3/<DOMAIN>/messages', {
                from: "hello@<DOMAIN>",
                to: 'test@mail.com',
                subject: "Subject text",
                text: "Body text"
            }).then(function(data){
                return data;
            }, function(error){
                //manage error
            })
        }

This is giving me a 401 Unauthorized error

UPDATE:

I have find this post where it's fixed --> Mailgun + AngularJS + Auhtentication for http post request

In my case, multipart is not needed.


回答1:


Looks like to use their API you need to get authenticated by the server first.




回答2:


Please see https://documentation.mailgun.com/api-intro.html#authentication. It looked like you need to set the API key in the URL.



来源:https://stackoverflow.com/questions/37931250/send-email-with-mailgun-in-angular

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