-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Demo to send E-Mail using mailgun.com
- Loading branch information
1 parent
a5a4575
commit fd2d2f6
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |