I am trying to send an email through mailgun rest service but I am facing a cross-domain problem.
I have tried many solutions, adding headers. But nothing is working.
Live the demo (just click the button to reproduce bug): https://bitcash.herokuapp.com/#/dashboard
Full code: https://github.com/Tyvain/bitcash
src/app/store/feed/feed.effects.ts
requestHeaders.append("Authorization", "Basic " + this.mailgunApiKey);
requestHeaders.append("Content-Type", "application/x-www-form-urlencoded");
this.http.request(new Request({
method: RequestMethod.Post,
url: "https://api.mailgun.net/v3/sandbox41db17f981b345018e03f5b1dbc281fa.mailgun.org/messages",
body: "from=" + action.payload.from
+ "&to=" + action.payload.to
+ "&subject=" + action.payload.subject
+ "&text=" + action.payload.text,
headers: requestHeaders
}))
Also tried this (not working):
requestHeaders.append("Authorization", "Basic " + this.mailgunApiKey);
requestHeaders.append("Content-Type", "application/x-www-form-urlencoded");
requestHeaders.append("Access-Control-Allow-Origin", "*");
requestHeaders.append("Access-Control-Allow-Credentials", "true");
requestHeaders.append("Access-Control-Allow-Methods", "POST, GET, OPTIONS");