Created
November 27, 2014 01:41
-
-
Save ryuheechul/96358f56ad8f142c5374 to your computer and use it in GitHub Desktop.
Alternative for parse.com’s cloud module Mandrill.
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
var mandrillApiKey; | |
var path = 'https://mandrillapp.com/api/1.0/messages/'; | |
exports.initialize = function(apiKey) { | |
mandrillApiKey = apiKey; | |
}; | |
exports.sendMail = function(params, options){ | |
callMandrill('send.json', params, options); | |
}; | |
exports.sendTemplate = function(params, options) { | |
callMandrill('send-template.json', params, options); | |
}; | |
function callMandrill(url, params, options) { | |
Parse.Cloud.httpRequest({ | |
method: 'POST', | |
headers: { | |
'Content-Type': 'application/json; charset=utf-8', | |
}, | |
url: path + url, | |
body: (function(){ | |
params.key = mandrillApiKey; | |
return params; | |
})(), | |
},options); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why do we need alternative?
UTF-8 characters such as Korean and Chinese are not sent through Parse’s Mandril cloud module.
So I just simply added 'charset=utf-8’ in HTTP header when using Mandril’s API.
Usage