nodemailer-mailgun-transport
Advanced tools
Comparing version 1.3.5 to 1.3.6
@@ -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(); | ||
}); | ||
}); | ||
}); | ||
}); |
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
21776
424
8
+ Addedagent-base@4.3.0(transitive)
+ Addedasync@2.5.0(transitive)
+ Addedasynckit@0.4.0(transitive)
+ Addedco@4.6.0(transitive)
+ Addeddebug@2.6.93.1.03.2.7(transitive)
+ Addedes6-promise@4.2.8(transitive)
+ Addedes6-promisify@5.0.0(transitive)
+ Addedform-data@2.2.0(transitive)
+ Addedhttp-proxy-agent@2.1.0(transitive)
+ Addedhttps-proxy-agent@2.2.4(transitive)
+ Addedinflection@1.12.0(transitive)
+ Addedis-stream@1.1.0(transitive)
+ Addedmailgun-js@0.13.1(transitive)
+ Addedms@2.0.02.1.3(transitive)
+ Addedpac-proxy-agent@2.0.2(transitive)
+ Addedpac-resolver@3.0.0(transitive)
+ Addedpromisify-call@2.0.4(transitive)
+ Addedproxy-agent@2.1.0(transitive)
+ Addedsocks-proxy-agent@3.0.1(transitive)
+ Addedtsscmp@1.0.6(transitive)
+ Addedwith-callback@1.0.2(transitive)
- Removedasync@1.5.22.6.4(transitive)
- Removedco@3.0.6(transitive)
- Removeddebug@2.2.0(transitive)
- Removedform-data@1.0.1(transitive)
- Removedinflection@1.7.2(transitive)
- Removedip@1.0.1(transitive)
- Removedmailgun-js@0.7.10(transitive)
- Removedms@0.7.1(transitive)
- Removedpac-proxy-agent@1.1.0(transitive)
- Removedpac-resolver@2.0.0(transitive)
- Removedproxy-agent@2.0.0(transitive)
- Removedq@1.4.1(transitive)
- Removedscmp@1.0.2(transitive)
Updatedmailgun-js@^0.13.1