loopback-connector-mailgun
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -84,4 +84,4 @@ var Mailgun = require('mailgun-js'), | ||
mailgunMessage.subject = options.subject || null; | ||
mailgunMessage.html = options.html || null; | ||
mailgunMessage.text = options.text || null; | ||
mailgunMessage.html = options.html || ''; | ||
mailgunMessage.text = options.text || ''; | ||
if (options.replyTo){ | ||
@@ -91,2 +91,32 @@ mailgunMessage['h:Reply-To'] = options.replyTo; | ||
if (options.attachments){ | ||
mailgunMessage.attachment = []; | ||
if (lo.isString(options.attachments)){ | ||
mailgunMessage.attachment.push(options.attachments); | ||
} else if (lo.isArray(options.attachments)){ | ||
for (var i in options.attachments){ | ||
mailgunMessage.attachment.push(options.attachments[i]); | ||
mailgunMessage['h:encoding'] = 'multipart/form-data'; | ||
} | ||
} | ||
} | ||
if (options.options){ | ||
lo.forEach(options.options,function (value,key) { | ||
mailgunMessage['o:' + key] = value; | ||
}); | ||
} | ||
if (options.var){ | ||
lo.forEach(options.var,function (value,key) { | ||
mailgunMessage['v:' + key] = value; | ||
}); | ||
} | ||
if (options.headers){ | ||
lo.forEach(options.headers,function (value,key) { | ||
mailgunMessage['h:' + key] = value; | ||
}); | ||
} | ||
connector.mailgun.messages().send(mailgunMessage, function (err,body) { | ||
@@ -93,0 +123,0 @@ fn(null, body); |
{ | ||
"name": "loopback-connector-mailgun", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Loopback connector module which allow to send emails via Mailgun", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -53,5 +53,16 @@ ## loopback-connector-mailgun | ||
text: "text message", | ||
html: "html <b>message</b>" | ||
html: "html <b>message</b>", | ||
attachments : [path.resolve('../client/images/an-image.jpg'))], | ||
var : { | ||
myVar1 : 'a custom value' | ||
}, | ||
headers : { | ||
"X-My-Header" : "My Custom header" | ||
} | ||
}) | ||
.then(function(response){}) | ||
.catch(function(err){}); | ||
.catch(function(err){}); | ||
###quick note on attachments | ||
Refer to Mailgun documentation on limitations concerning attachments. | ||
The attachments property can be either an array or a string. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7123
126
67