JSPM

lb-connector-mandrill

0.0.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 303
  • Score
    100M100P100Q94832F
  • License MIT

Loopback connector module which allow to send emails via Mandrill

Package Exports

  • lb-connector-mandrill

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (lb-connector-mandrill) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

lb-connector-mandrill

lb-connector-mandrill is the Loopback connector module which allow to send emails via Mandrill.

1. Installation

npm install lb-connector-mandrill --save

2. Configuration

datasources.json

{
    "mandrill": {
        "connector": "lb-connector-mandrill",
        "apikey": "[your api key here]"
    }
}

model-config.json

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

Additionaly you can set defaults

{
    "mandrill": {
        "connector": "lb-connector-mandrill",
        "apikey": "[your api key here]",
        "defaults": {
            "account": "evenemento",
            "inline_css": true
        }
    }
}

Configuration in JavaScript

var DataSource = require('loopback-datasource-juggler').DataSource;
var dsMandrill = new DataSource('lb-connector-mandrill', {
    apikey: '[your api key here]'
});
loopback.Email.attachTo(dsMandrill);

3. Use

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');
        return;
    }
    console.log(result);
});

Some advantages - now you can use templates from Mandrill

loopback.Email.send({
    to: "test@to.com",
    from: "test@from.com",
    subject: "subject",
    template: {
        name: "signup-confirm",
        content: {
            name: "NewUser Name",
            accountId: "123456"
        }
    }
},
function(err, result) {
    if(err) {
        console.log('Upppss something crash');
        return;
    }
    console.log(result);
});