Skip to content

Commit

Permalink
Demo to send E-Mail using mailgun.com
Browse files Browse the repository at this point in the history
  • Loading branch information
gregorwolf committed Aug 8, 2016
1 parent a5a4575 commit fd2d2f6
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
10 changes: 10 additions & 0 deletions odatapublic/mailgun.xshttpdest
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
host = "api.mailgun.net";
port = 443;
pathPrefix = "/v3/sandbox864bff1527b245f583ea2373c52f0cc3.mailgun.org";
proxyType = http;
proxyHost = "proxy-trial";
proxyPort = 8080;
authType = basic;
useSSL = true;
timeout = 30000;
sslAuth = client;
30 changes: 30 additions & 0 deletions odatapublic/mailgun.xsjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
var destination_package = "de.linuxdozent.gittest.odatapublic";
var destination_name = "mailgun";
var message;
var he;


try {
var dest = $.net.http.readDestination(destination_package, destination_name);
var client = new $.net.http.Client();

var req = new $.web.WebRequest($.net.http.POST, "/messages");
req.headers.set('Content-Type', encodeURIComponent("application/x-www-form-urlencoded"));

req.parameters.set("domain","sandbox864bff1527b245f583ea2373c52f0cc3.mailgun.org");
req.parameters.set("from","gregor@sandbox864bff1527b245f583ea2373c52f0cc3.mailgun.org");
req.parameters.set("to","gregor.wolf@gmail.com");
req.parameters.set("subject","Test subject");
req.parameters.set("text","Test text");

client.request(req, dest);
var response = client.getResponse();


$.response.contentType = "text/html";
$.response.setBody(response.body.asString());
$.response.status = $.net.http.OK;
} catch (e) {
$.response.contentType = "text/plain";
$.response.setBody(e.message);
}

0 comments on commit fd2d2f6

Please # to comment.