Skip to content

Instantly share code, notes, and snippets.

@srubin
Created April 24, 2015 17:46
Show Gist options
  • Save srubin/fc39120e82b9f4ead0bc to your computer and use it in GitHub Desktop.
Save srubin/fc39120e82b9f4ead0bc to your computer and use it in GitHub Desktop.
Send emails in Kinoma with Mailgun
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