Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nodemailer-mailgun-transport

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nodemailer-mailgun-transport - npm Package Compare versions

Comparing version 1.3.5 to 1.3.6

4

package.json

@@ -5,3 +5,3 @@ {

"description": "A transport module to use with nodemailer to leverage Mailgun's REST API",
"version": "1.3.5",
"version": "1.3.6",
"repository": {

@@ -42,3 +42,3 @@ "type": "git",

"consolidate": "^0.14.0",
"mailgun-js": "0.7.10"
"mailgun-js": "^0.13.1"
},

@@ -45,0 +45,0 @@ "devDependencies": {

@@ -38,2 +38,6 @@ 'use strict';

var transformList = [
'replyTo'
];
module.exports = function (options) {

@@ -71,5 +75,5 @@ return new MailgunTransport(options);

},
function(done){
function(done){
//convert address objects or array of objects to strings if present
var targets =['from','to','cc','bcc'];
var targets =['from','to','cc','bcc','replyTo'];
var count =0;

@@ -81,3 +85,3 @@ for (var target of targets){

var addresses = typeof addrsData === 'object' ? [addrsData] : addrsData;
for (var addr of addresses ){
for (var addr of addresses ){
if (Array.isArray(addr)){

@@ -92,5 +96,5 @@ for (var add of addr){

}
} else{
} else{
if(addr.address){
var final = addr.name ? addr.name + ' <' + addr.address + '>' : addr.address
var final = addr.name ? addr.name + ' <' + addr.address + '>' : addr.address
addrs.push(final);

@@ -103,3 +107,3 @@ }

count++;
count == 4 ? done():null;
count == 5 ? done():null;
}

@@ -141,4 +145,14 @@ },

delete mail.data.headers;
delete mailData.headers;
transformList.forEach( function(key) {
if (mailData[key]) {
switch (key) {
case 'replyTo':
mailData['h:Reply-To'] = mailData[key];
delete mailData[key];
}
}
});
var options = pickBy(mailData, function (value, key) {

@@ -155,2 +169,5 @@ if (whitelistExact.indexOf(key) !== -1) {

self.messages.send(options, function (err, data) {
if (data) {
data.messageId = data.id;
}
callback(err || null, data);

@@ -157,0 +174,0 @@ });

@@ -15,3 +15,6 @@ var chai = require('chai');

this.sinon.stub(this.transport.messages, 'send').callsArg(1);
this.sinon.stub(this.transport.messages, 'send').callsArgWith(1, null, {
id: '<20111114174239.25659.5817@samples.mailgun.org>',
message: 'Queued. Thank you.'
});
});

@@ -47,3 +50,3 @@

data: data
}, function () {
}, function (err, info) {
expect(self.transport.messages.send).to.have.been.calledWith({

@@ -71,2 +74,4 @@ from: 'from@bar.com',

});
expect(err).to.be.null;
expect(info.messageId).to.equal('<20111114174239.25659.5817@samples.mailgun.org>');
done();

@@ -93,3 +98,3 @@ });

data: data
}, function () {
}, function (err, info) {
expect(self.transport.messages.send).to.have.been.calledOnce;

@@ -103,2 +108,4 @@ var call = self.transport.messages.send.getCall(0);

expect(attachment.knownLength).to.equal(122);
expect(err).to.be.null;
expect(info.messageId).to.equal('<20111114174239.25659.5817@samples.mailgun.org>');
done();

@@ -120,3 +127,3 @@ });

data: data
}, function () {
}, function (err, info) {
expect(self.transport.messages.send).to.have.been.calledWith({

@@ -129,4 +136,6 @@ from: 'from@bar.com',

});
expect(err).to.be.null;
expect(info.messageId).to.equal('<20111114174239.25659.5817@samples.mailgun.org>');
done();
});
});
});

@@ -148,3 +157,3 @@ });

data: data
}, function () {
}, function (err, info) {
expect(self.transport.messages.send).to.have.been.calledWith({

@@ -156,2 +165,4 @@ from: 'from@bar.com',

});
expect(err).to.be.null;
expect(info.messageId).to.equal('<20111114174239.25659.5817@samples.mailgun.org>');
done();

@@ -181,3 +192,3 @@ });

data: data
}, function () {
}, function (err, info) {
expect(self.transport.messages.send).to.have.been.calledWith({

@@ -189,2 +200,4 @@ from: 'from@bar.com',

});
expect(err).to.be.null;
expect(info.messageId).to.equal('<20111114174239.25659.5817@samples.mailgun.org>');
done();

@@ -195,3 +208,3 @@ });

describe('with simple address objects', function () {
describe('with simple address objects', function () {
it('should convert to standard address format', function (done) {

@@ -210,3 +223,3 @@ var self = this;

data: data
}, function () {
}, function (err, info) {
expect(self.transport.messages.send).to.have.been.calledWith({

@@ -220,2 +233,4 @@ from: 'From <from@bar.com>',

});
expect(err).to.be.null;
expect(info.messageId).to.equal('<20111114174239.25659.5817@samples.mailgun.org>');
done();

@@ -226,3 +241,3 @@ });

describe('with address objects missing data or having multiple entries (array of objects)', function () {
describe('with address objects missing data or having multiple entries (array of objects)', function () {
it('should convert to standard address format and skip missing data', function (done) {

@@ -236,2 +251,3 @@ var self = this;

bcc: [{"name":'Bcc', "address":'bcc@bar.com'}, {"name":null, "address":"bcc2@bar.com"}, {"address":"bcc3@bar.com"},{"name":"Bcc4"}],
replyTo: {"name":'ReplyTo', "address":'replyto@bar.com'},
subject: 'Subject',

@@ -242,3 +258,3 @@ text: 'Hello',

data: data
}, function () {
}, function (err, info) {
expect(self.transport.messages.send).to.have.been.calledWith({

@@ -249,5 +265,8 @@ from: 'from@bar.com',

bcc: 'Bcc <bcc@bar.com>,bcc2@bar.com,bcc3@bar.com',
'h:Reply-To': 'ReplyTo <replyto@bar.com>',
subject: 'Subject',
text: 'Hello'
});
expect(err).to.be.null;
expect(info.messageId).to.equal('<20111114174239.25659.5817@samples.mailgun.org>');
done();

@@ -258,2 +277,29 @@ });

describe('with a replyTo address set', function () {
it('should convert it to "h:Reply-To" property ', function (done) {
var self = this;
var data = {
from: 'from@bar.com',
to: 'to@bar.com',
replyTo: 'replyto@bar.com',
subject: 'Subject',
text: 'Hello',
};
this.transport.send({
data: data
}, function (err, info) {
expect(self.transport.messages.send).to.have.been.calledWith({
from: 'from@bar.com',
to: 'to@bar.com',
'h:Reply-To': 'replyto@bar.com',
subject: 'Subject',
text: 'Hello'
});
expect(err).to.be.null;
expect(info.messageId).to.equal('<20111114174239.25659.5817@samples.mailgun.org>');
done();
});
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc