Created
April 24, 2015 17:46
-
-
Save srubin/fc39120e82b9f4ead0bc to your computer and use it in GitHub Desktop.
Send emails in Kinoma with Mailgun
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
Handler.bind("/sendEmail", { | |
onInvoke: function(handler, message) { | |
var apiKey = "key-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; | |
var sandboxUrl = "api.mailgun.net/v3/sandboxAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA.mailgun.org/messages"; | |
var messageUrl = "https://api:" + apiKey + "@" + sandboxUrl; | |
var message = new Message(messageUrl); | |
message.method = "POST"; | |
var emailDetails = { | |
from: 'Mailgun Sandbox <postmaster@sandboxAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA.mailgun.org>', | |
to: 'Your User <username@example.com>', | |
subject: 'This is the subject of the email', | |
text: 'Here is the body of the email.' | |
} | |
message.requestText = serializeQuery(emailDetails); | |
message.setRequestHeader("Content-Length", message.requestText.length); | |
message.setRequestHeader("Content-Type", 'application/x-www-form-urlencoded'); | |
handler.invoke(message, Message.TEXT); | |
}, | |
onComplete: function(handler, message, json) { | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment