Giter Club home page Giter Club logo

clearblade-sendgrid-email-integration's Introduction

ipm package: sendgrid-email-library

Overview

SendGrid is an email service trusted by developers and marketers for time-savings, scalability and delivery expertise.

To get an overview of SendGrid features and functionality click here.

If any suggestions or addition of new methods create a pull request. For further support, comment or create issues on this repo.

This is an ipm package, which contains one or more reusable assets within the ipm Community. The 'package.json' in this repo is a ipm spec's package.json, here, which is a superset of npm's package.json spec, here.

Browse ipm Packages

Setup

  • Create a free SendGrid Account.
  • Log into your SendGrid account, and view the Settings > API Keys tab. Create an API Key with full access to "Mail Send" rights.
  • Update SendGridConstants Library
// TODO Use your own credentials, these are examples
var SEND_GRID_TOKEN = "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"
var ORIGIN_EMAIL = "[email protected]";
var EMAIL_RECIPIENTS = ["[email protected]"]
  • Add 'SendGridEmail' as a dependency to any of your code services (Settings > Requires > Add)

Usage

Run ExampleSendEmailPlaintext Code Service, also here for reference:

var sgEmail = SendGridEmail(SEND_GRID_TOKEN, ORIGIN_EMAIL)
sgEmail.SendEmailToList("Alert!", "ClearBlade Email Alert", EMAIL_RECIPIENTS, function(err, data){
     if(err){
         resp.error(err)
     }
     var message = "Successful email sent!"
     resp.success(message);
});

Assets

Code Services

Examples:

  • ExampleSendEmailPlaintext - Sends an email with static plaintext content
  • ExampleSendEmailParameterized - Sends an email with a dynamic plaintext content with parameter passed into Code Service
  • ExampleSendEmailHTML - Sends an email with static HTML content
  • ExampleSendEmailAdvanced - Sends an email with dynamic HTML Content passed into Code Service

Tests:

  • TestSendEmailMissingAuthToken - Tests init and validation logic
  • TestSendEmailMissingOriginEmail - Tests validation of origin email

Code Libraries

  • SendGridConstants - This lib has constants which needs to be set by the user to test the example services. It is recommended to store keys in the constants library for centralized management of keys.
  • SendGridEmail - Described in the API section.

API

Typedefs

callback : function

This callback is displayed as part of sgEmail.

SendGridEmail : Object

Email service trusted by developers and marketers for time-savings, scalability, and delivery expertise.

callback : function

This callback is displayed as part of sgEmail.

Kind: global typedef

Param Type
err Object
resp Object

SendGridEmail : Object

Email service trusted by developers and marketers for time-savings, scalability, and delivery expertise.

Kind: global typedef

Param Type
authToken string
originEmail string

Example

var sgEmail = SendGridEmail(SEND_GRID_TOKEN, ORIGIN_EMAIL)

SendGridEmail.SendEmailToList(emailBody, subject, recipientList, callback) โ‡’ Object

SendEmailToList = Sends email with given subject and body to a list of recipients.

Kind: static method of SendGridEmail
Returns: Object - response, as specified in sendgrid api

Param Type Description
emailBody string body of your email
subject string subject of your email
recipientList Array.<string> list of recipients
callback callback

Example

//Assign relevant values to the variables and constants
var sgEmail = SendGridEmail(SEND_GRID_TOKEN, ORIGIN_EMAIL)
sgEmail.SendEmailToList(message, subject, emailRecipientList, function(err, data){
     if(err){
         resp.error(err)
     }
     var message = "Successful email sent!"
     resp.success(message);
});

clearblade-sendgrid-email-integration's People

Contributors

rreinold avatar yashjain28 avatar

Watchers

 avatar

Forkers

clearblade

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.