Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
sendEmailTest(from:string, to:string, subject:string, text:string, html:string, inlines:Array<any>):Promise<any> {
var mailgunUrl = "https://api.mailgun.net/v3/" + this.domain + "/messages";
var mailgunApiKey = "api:key-e0b78e9e1c5e1c3135d3dfdf47ec2c60"
var headers = new Headers();
headers.append('Authorization', "Basic " + mailgunApiKey); // base64 encoding is missing
headers.append('Content-Type', "application/x-www-form-urlencoded");
//headers.append("enctype", "multipart/form-data");
var body:FormData = new FormData();
//body.append("enctype", "multipart/form-data");
body.append('from', 'Mailgun Sandbox <postmaster@sandbox26d580144f334d8baf9ffa699171a282.mailgun.org>');
body.append('to', 'my register <myregistercd@gmail.com>');
body.append('subject', subject);
body.append('text', text);
body.append('html', html);
//inlines.forEach((inline) => {
//body.append('inline', inline.data, inline.filename);
//});
let options = new RequestOptions({ headers: headers });
return this.http.post( mailgunUrl, options)
.map(res => res.json())
.toPromise();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment