@snstarosciak wrote:
Hey everyone,
I'm running into an issue trying to use Mailgun in my Ionic 3 app. When I run the function to send mail in the browser, I have a Chrome plugin that allows me to enable CORS and it can send the message just fine. However, in my app on my device, when I try to send an email, I get an error:
{ "body": { "isTrusted": true}, "status": 0, "ok": false, {}, "type": 3"url": null}
I believe this is related to CORS.
I even tried adding this line to my
index.html
file but all it did was cause all sorts of errors with trying to talk to my REST API:
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
Here is the relevant code for the function that sends the email:
send(recipient: string, subject: string, message) { var requestHeaders = new Headers(); requestHeaders.append("Authorization", "Basic " + this.mailgunApiKey); requestHeaders.append("Content-Type", "application/x-www-form-urlencoded"); return this.http.request(new Request({ method: RequestMethod.Post, url: `${this.mailgunUrl}/messages`, body: "from=bugs@bandly.com&to=" + recipient + "&subject=" + subject + "&text=" + message, headers: requestHeaders })); }
Does anyone have any insight into what I could missing here?
Posts: 5
Participants: 2