Skip to content

younes200/loopback-connector-mailjet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

loopback-connector-mailjet

Loopback connector module which allow to send emails via Mailjet.

1. Installation

npm install loopback-connector-mailjet --save

2. Configuration

datasources.json

{
    "mailjet": {
        "connector": "loopback-connector-mailjet",
        "apiKey": "${MAILJET_API_KEY}",
        "apiSecret":"${MAILJET_API_SECRET}"
    }
}

model-config.json

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

Additionaly you can set defaults or connection options

{
    "mailjet": {
        "connector": "loopback-connector-mailjet",
        "apikey": "[your api key here]",
        "default": {
            "fromEmail": "[email protected]",
            "fromName": "Anna"
        },
        "options": {
            "url": "api.mailjet.com", 
            "version": "v3.1",
            perform_api_call: false
        },
        
    }
}

3. Use

Basic option same as built in Loopback. Returns a Promise

loopback.Email.send({
    to: "[email protected]",
    from: "[email protected]",
    subject: "subject",
    text: "text message",
    html: "html <b>message</b>",
    headers : {
        "X-My-Header" : "My Custom header"
    }
})
.then(function(response){})
.catch(function(err){});

Basic option for templates

loopback.Email.send({
    to: "[email protected]",
    from: "[email protected]",
    subject: "subject",
    templateId: "11111",
    templateVars: {
      "VAR": "VALUE"
    }
})
.then(function(response){})
.catch(function(err){});

License

Copyright (c) 2016 Interactive Object . Licensed under the MIT license.

Releases

No releases published

Packages

No packages published