How can my Parse.com app send an email using JavaScript? How can my Parse.com app send an email using JavaScript? javascript javascript

How can my Parse.com app send an email using JavaScript?


Parse Cloud Code Modules now support sending email through a number of Cloud Mail Providers:


Here is the android version for @uudaddy's answer

public void sendMail(View view) {    Map<String, String> params = new HashMap<>();    params.put("text", "Sample mail body");    params.put("subject", "Test Parse Push");    params.put("fromEmail", "someone@example.com");    params.put("fromName", "Source User");    params.put("toEmail", "other@example.com");    params.put("toName", "Target user");    ParseCloud.callFunctionInBackground("sendMail", params, new FunctionCallback<Object>() {        @Override        public void done(Object response, ParseException exc) {            Log.e("cloud code example", "response: " + response);        }    });}

Server side JS Code(main.js) Parse Cloud

Parse.Cloud.define("sendMail", function(request, response) {var Mandrill = require('mandrill');Mandrill.initialize('12AkxxxxxxxxxxxxxxrZEg');Mandrill.sendEmail({message: {text: request.params.text,subject: request.params.subject,from_email: request.params.fromEmail,from_name: request.params.fromName,to: [{email: request.params.toEmail,name: request.params.toName}]},async: true},{success: function(httpResponse) {console.log(httpResponse);response.success("Email sent!");},error: function(httpResponse) {console.error(httpResponse);response.error("Uh oh, something went wrong");}});});