GithubHelp home page GithubHelp logo

rickyngk / loopback-connector-sendgrid Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cellarise/loopback-connector-sendgrid

0.0 2.0 0.0 75 KB

Loopback connector to send emails via SendGrid

License: MIT License

JavaScript 95.99% Gherkin 4.01%

loopback-connector-sendgrid's Introduction

Installation

npm install loopback-connector-sendgrid --save

Configuration

Sendgrid username and password

Use the following configuration if you have a username and password.

datasources.json

{
    "sendgrid": {
        "connector": "loopback-connector-sendgrid",
        "api_user": '[your username here]'
        "api_key": '[your password here]'
    }
}

model-config.json

{
    "Email": {
        "dataSource": "sendgrid",
        "public": false
    }
}

Configuration in JavaScript

var DataSource = require('loopback-datasource-juggler').DataSource;
var dsSendGrid = new DataSource('loopback-connector-sendgrid', {
    api_user: '[your username here]'
    api_key: '[your password here]'
});
loopback.Email.attachTo(dsSendGrid);

Sendgrid API key

Use the following configuration if you have an api key.

datasources.json

{
    "sendgrid": {
        "connector": "loopback-connector-sendgrid",
        "api_key": '[your api key here]'
    }
}

model-config.json

{
    "Email": {
        "dataSource": "sendgrid",
        "public": false
    }
}

Configuration in JavaScript

var DataSource = require('loopback-datasource-juggler').DataSource;
var dsSendGrid = new DataSource('loopback-connector-sendgrid', {
    api_key: '[your api key here]'
});
loopback.Email.attachTo(dsSendGrid);

Usage

Basic option same as built in Loopback

loopback.Email.send({
    to: "[email protected]",
    from: "[email protected]",
    subject: "subject",
    text: "text message",
    html: "html <b>message</b>"
},
function(err, result) {
    if(err) {
        console.log('Upppss something crash');
        return;
    }
    console.log(result);
});

Send with template:

loopback.Email.send({
    to: "[email protected], [email protected]",
    from: "[email protected]",
    subject: "subject",
    sub: {
        ":name": ["User-1", "User-2"]
    },
    filters: {
        templates: {
            settings: {
                enable: 1,
                template_id: "template-id"
            }
        }
    }
},
function(err, result) {
    if(err) {
        console.log('Upppss something crash');
        return;
    }
    console.log(result);
});

License

MIT License (MIT). All rights not explicitly granted in the license are reserved.

Copyright (c) 2015 John Barry

Dependencies

[email protected] - "MIT License (MIT)", documented by npm-licenses.

loopback-connector-sendgrid's People

Contributors

johnmbarry avatar mchmielarski avatar rickyngk avatar

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.