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.
看起来要使用它们的API,您需要首先由服务器进行身份验证。
Please see https://documentation.mailgun.com/api-intro.html#authentication . It looked like you need to set the API key in the URL.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.