jlainog / parse-mandrill-sendTemplate

this is a parse cloud module to send template mails from mandrill

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

parse-mandrill-sendTemplate

this is a parse cloud module to send template mails from mandrill

Usage Mandrill Send Template API:

Fist copy the mandrillTemplateSend.js to your cloud folder generate from parse

Take the method in main.js and pasted in your own main.js, look you need to add you api key there

    var Mandrill = require('cloud/mandrillTemplateSend.js')
Mandrill.initialize('YOUR MANDRILL API KEY');

The template_content is required but this is ignored so you can leave as it is

  template_content: [{
            name: "example name",
            content: "example content" //Those are required but they are ignored
        }]

Finally you can call it using REST parse api

    POST /1/functions/sendTemplate HTTP/1.1
    Host: api.parse.com
    X-Parse-Application-Id: Your Parse App Id
    X-Parse-REST-API-Key: Your Parse REST API Key
{
    "templateName" : "Your template name",
    "toEmail" : "the mail you want to send",
    "toName" : "the name of whom you are sending"
}

Modifications to send to multiple mails

if you wish to send this to multiple mails you can change this:

    to: [{
            email: request.params.toEmail,
            name: request.params.toName
        }],

to this:

    to: request.params.to,

in the main.js method
Parse.Cloud.define("sendTemplate", function(request, response),
and then in the REST call you do:

    POST /1/functions/sendTemplate HTTP/1.1
    Host: api.parse.com
    X-Parse-Application-Id: Your Parse App Id
    X-Parse-REST-API-Key: Your Parse REST API Key
{
  "templateName":"Your template name",
  "to":[
    {
      "email" :"the mail you want to send",
      "name" :"the name of whom you are sending"
    },
    {
      "email" : "the mail you want to send",
      "name" : "the name of whom you are sending"
    },
    {
      "email" : "the mail you want to send",
      "name" : "the name of whom you are sending"
    }
  ]
}

About

this is a parse cloud module to send template mails from mandrill

License:MIT License


Languages

Language:JavaScript 100.0%