Coder Social home page Coder Social logo

mymailcloudmodule's Introduction

Overview

This sample Cloud Module used in the Integrating with Third Party Service Tutorial to show developers how to create a Cloud Module. The module showcases sending email using the Mailgun service. To use the official Mailgun module, head over to the Mailgun Cloud Module guide.

Mailgun is a set of powerful APIs that allow you to send, receive, track and store email effortlessly. You can check out their service at www.mailgun.com. To use this module, you will need to head over to the Mailgun website and create an account.

Installation

  1. Clone this respository to get the Cloud Module.
git clone https://github.com/ParsePlatform/MyMailCloudModule.git
  1. Copy myMailModule-1.0.0.js over to your Cloud Code Directory, placing it in the cloud directory.

Usage

To use the module in your Cloud Code functions, start by requiring the module and initializing it with your credentials:

var client = require('cloud/myMailModule-1.0.0.js');
client.initialize('myDomainName', 'myAPIKey');

Then inside of your Cloud Code function, you can use the sendEmail function to fire off some emails:

Parse.Cloud.define("sendEmailToUser", function(request, response) {
  client.sendEmail({
    to: "[email protected]",
    from: "[email protected]",
    subject: "Hello from Cloud Code!",
    text: "Using Parse and My Mail Module is great!"
  }).then(function(httpResponse) {
    response.success("Email sent!");
  }, function(httpResponse) {
    console.error(httpResponse);
    response.error("Uh oh, something went wrong");
  });
});

This function takes two parameters. The first is a hash with the mail parameters you want to include in the request. The typical ones are from, to, subject and text, but you can find the full list on their documentation page. The second parameter to this function is an object with a success and an error field containing two callback functions.

Once you've deployed your Cloud Code function and this Cloud Module to Parse, you can test it out. The example below shows how to do this using cUrl:

curl -X POST \
  -H "X-Parse-Application-Id: YOUR_APPLICATION_ID" \
  -H "X-Parse-REST-API-Key: YOUR_REST_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ }' \
  https://api.parse.com/1/functions/sendEmailToUser

For additional information about this Cloud Module, take a look at the API Reference.

mymailcloudmodule's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.