Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed custom envelope bug, fixes #79

  • Loading branch information...
commit d2d3debcd5f855e7aa66cce6b71ec85c23b4e328 1 parent a9acb36
Andris Reinman authored
Showing with 35 additions and 2 deletions.
  1. +1 −1  lib/engines/stub.js
  2. +2 −1  lib/nodemailer.js
  3. +32 −0 test/nodemailer.js
View
2  lib/engines/stub.js
@@ -31,7 +31,7 @@ StubTransport.prototype.sendMail = function(emailMessage, callback) {
});
emailMessage.on("end", function(){
- callback(null, {message: output});
+ callback(null, {message: output, envelope: emailMessage.getEnvelope()});
});
emailMessage.streamMessage();
View
3  lib/nodemailer.js
@@ -164,7 +164,8 @@ Nodemailer.prototype.setGeneralOptions = function(){
}
var acceptedFields = ["from", "sender", "to", "subject", "replyTo", "debug",
- "reply_to", "cc", "bcc", "body", "text", "html"],
+ "reply_to", "cc", "bcc", "body", "text", "html",
+ "envelope"],
mailOptions = {},
keys = Object.keys(this.options),
key;
View
32 test/nodemailer.js
@@ -75,6 +75,38 @@ exports["General tests"] = {
test.ok(!response.message.match(new RegExp(regex)));
test.done();
})
+ },
+
+ "Use custom envelope": function(test){
+ var transport = nodemailer.createTransport("Stub"),
+ mailOptions = {
+ from: "sender1@tr.ee",
+ to: "receiver1@tr.ee",
+ envelope: {
+ from: "sender2@tr.ee",
+ to: "receiver2@tr.ee",
+ }
+ };
+
+ transport.sendMail(mailOptions, function(error, response){
+ test.ifError(error);
+ test.deepEqual(response.envelope, {from:'sender2@tr.ee',to: [ 'receiver2@tr.ee' ],stamp: 'Postage paid, Par Avion'})
+ test.done();
+ })
+ },
+
+ "Use default envelope": function(test){
+ var transport = nodemailer.createTransport("Stub"),
+ mailOptions = {
+ from: "sender1@tr.ee",
+ to: "receiver1@tr.ee"
+ };
+
+ transport.sendMail(mailOptions, function(error, response){
+ test.ifError(error);
+ test.deepEqual(response.envelope, {from:'sender1@tr.ee',to: [ 'receiver1@tr.ee' ],stamp: 'Postage paid, Par Avion'})
+ test.done();
+ })
}
};
Please sign in to comment.
Something went wrong with that request. Please try again.