loopback-connector-sendgrid

Loopback connector module which allow to send emails via SendGrid


License
MIT
Install
npm install loopback-connector-sendgrid@1.2.4

Documentation

loopback-connector-sendgrid

view on npm npm module downloads per month Dependency status Build Status Code Climate Test Coverage

Loopback connector module which allow to send emails via SendGrid

Installation

npm install loopback-connector-sendgrid --save

Configuration

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);

Sendgrid settings

Using sendgrid mail_settings and tracking_settings: datasources.json

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

Usage

Basic option same as built in Loopback:

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

Advanced options using the sendGridConfig option:

loopback.Email.send({
    to: "test@to.com",
    from: "test@from.com",
    subject: "subject",
    text: "text message",
    html: "html <b>message</b>",
    sendGridConfig: {
        personalizations: ...,
        templateId: ...,
        sections: ...,
        headers: ...,
        categories: [{category: 'your-category'}],
        sendAt: ...,
        batchId: ...,
        asm: ...,
        ipPoolName: ...,
        replyTo: ...
    }
},
function(err, result) {
    if(err) {
        console.log('Upppss something crash', err);
        return;
    }
    console.log(result);
});

API

documented by jsdoc-to-markdown.

Changelog

Type ID Summary
Version: 2.2.4 - released 2017-10-21
Non-functional MDLPCNSG-49

Package: Update package dependencies

Version: 2.2.3 - released 2017-10-11
Non-functional MDLPCNSG-48

Package: Update package dependencies

Version: 2.2.2 - released 2017-09-02
Non-functional MDLPCNSG-47

Package: Update package dependencies

Version: 2.2.1 - released 2017-05-28
Non-functional MDLPCNSG-46

Package: Update package dependencies

Version: 2.2.0 - released 2017-04-23
Bug MDLPCNSG-45

Bugfix: renamed addUniqueArg to addCustomArg

Version: 2.1.5 - released 2017-04-02
Non-functional MDLPCNSG-44

Package: Update package dependencies

Version: 2.1.4 - released 2017-03-23
Non-functional MDLPCNSG-43

Package: Update package dependencies

Version: 2.1.3 - released 2016-12-31
Non-functional MDLPCNSG-42

Package: Update package dependencies

Version: 2.1.2 - released 2016-11-14
Bug MDLPCNSG-41

Fix personalizations #22

Version: 2.1.1 - released 2016-11-05
Non-functional MDLPCNSG-40

Package: Fix version of development dependency - eslint

Version: 2.1.0 - released 2016-11-05
Non-functional MDLPCNSG-39

Remove bin directory

Minor MDLPCNSG-38

Add support for cc/bcc emails #19

Version: 2.0.6 - released 2016-09-03
Bug MDLPCNSG-37

Fix faulty 'to' parsing #15

Version: 2.0.5 - released 2016-08-29
Bug MDLPCNSG-36

Fix sendGridLib.SendGrid is not a function #14

Version: 2.0.4 - released 2016-08-25
Non-functional MDLPCNSG-35

Readme: Clarify type of sendGridConfig.categories - must be an object, not string #11

Non-functional MDLPCNSG-32

Package: Update package dependencies

Non-functional MDLPCNSG-33

Package: Update package dependencies

Bug MDLPCNSG-34

Fix Invalid type of To email (found) #13

Version: 2.0.3 - released 2016-07-09
Bug MDLPCNSG-31

Package: Add test steps for 2.0.2 and fix readme

Version: 2.0.1 - released 2016-07-08
Bug MDLPCNSG-30

Package: Fix library to use sendgrid web APIv3 configuration

Version: 2.0.0 - released 2016-07-08
Non-functional MDLPCNSG-29

Package: Move babel-core from dependencies to devDependencies

Non-functional MDLPCNSG-28

Package: Upgrade Sendgrid dependency from ^2.0.0 to ^3.0.4 (upgraded in version 1.2.4)

Version: 1.2.4 - released 2016-07-07
Non-functional MDLPCNSG-24

Package: update usage documentation to describe configuration of sendgrid api key

Bug MDLPCNSG-27

Email connector: Fix filters reference to higher scoped var sendgridFilters

Non-functional MDLPCNSG-26

Package: Update package dependencies

Non-functional MDLPCNSG-25

Package: Update package dependencies

Version: 1.2.3 - released 2016-02-16
Non-functional MDLPCNSG-23

Package: Update package dependencies

Version: 1.2.2 - released 2015-11-26
Non-functional MDLPCNSG-22

Package: Update package dependencies

Version: 1.2.0 - released 2015-10-05
Feature MDLPCNSG-16

Email connector: Add support for api_key

Version: 1.1.4 - released 2015-08-25
Non-functional MDLPCNSG-15

Package: Update development dependencies and configure for travis-ci

Version: 1.1.3 - released 2015-07-21
Non-functional MDLPCNSG-14

Package: Update package dependencies

Version: 1.1.2 - released 2015-07-14
Non-functional MDLPCNSG-13

Package: Update package dependencies

Version: 1.1.1 - released 2015-07-01
Non-functional MDLPCNSG-12

Package: Update package dependencies

Version: 1.1.0 - released 2015-06-30
Bug MDLPCNSG-11

Email connector: From address specification mismatch

Feature MDLPCNSG-10

Email connector: Send message attachments

Version: 1.0.3 - released 2015-04-20
Non-functional MDLPCNSG-9

Package: Update package dependencies

Version: 1.0.2 - released 2015-02-23
Non-functional MDLPCNSG-8

Package: Update package dependencies

Non-functional MDLPCNSG-7

Package: Update eslint configuration, test.js runner and dev dependencies

Version: 1.0.1 - released 2015-02-03
Bug MDLPCNSG-6

Email connector: Email subject line not set

Version: 1.0.0 - released 2015-02-03
Feature MDLPCNSG-5

Email connector: Add sendgrid filters passthrough from datasource

Feature MDLPCNSG-4

Email connector: Add sendgrid options passthrough from datasource

Version: 0.1.1 - released 2015-02-03
Non-functional MDLPCNSG-3

Package: Update package dependencies

Version: 0.1.0 - released 2015-02-02
Feature MDLPCNSG-2

Email connector: Add a loopback connector for sending emails from SendGrid

License

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

Copyright (c) 2015 John Barry

Dependencies

loopback-connector-sendgrid@2.2.3 - "MIT License (MIT)", documented by npm-licenses.