问题
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