Loopback connector module which allow to send emails via Mailjet.
npm install loopback-connector-mailjet --save
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
},
}
}
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){});
Copyright (c) 2016 Interactive Object . Licensed under the MIT license.