Permalink
Browse files

Merge pull request #116 from goodeggs/custom_date

Use custom Date header value if specified in options
  • Loading branch information...
2 parents a1c36aa + 1a5780f commit 67ab6b2e0e5ac7be6d6d53dfa784e59a7ba48531 @andris9 andris9 committed Nov 6, 2012
Showing with 21 additions and 2 deletions.
  1. +5 −1 lib/nodemailer.js
  2. +1 −1 package.json
  3. +15 −0 test/nodemailer.js
View
@@ -262,7 +262,11 @@ Nodemailer.prototype.setModuleHeaders = function(){
this.mailcomposer.addHeader("X-Mailer", this.generateUserAgentString());
// Date
- this.mailcomposer.addHeader("Date", new Date().toUTCString());
+ if(this.options.date){
+ this.mailcomposer.addHeader("Date", this.options.date)
+ }else{
+ this.mailcomposer.addHeader("Date", new Date().toUTCString());
+ }
// Message ID
if(this.options.messageId){
View
@@ -1,7 +1,7 @@
{
"name": "nodemailer",
"description": "Easy to use module to send e-mails, supports unicode and SSL/TLS",
- "version": "0.3.30",
+ "version": "0.3.31",
"author" : "Andris Reinman",
"maintainers":[
{
View
@@ -76,6 +76,21 @@ exports["General tests"] = {
test.done();
})
},
+
+ "Use custom Date value": function(test){
+ var transport = nodemailer.createTransport("Stub"),
+ mailOptions = {
+ date: "Fri, 5 Nov 2012 09:41:00 -0800"
+ };
+
+ transport.sendMail(mailOptions, function(error, response){
+ test.ifError(error);
+ test.ok(response.message.match(/Date:\s*Fri, 5 Nov 2012 09:41:00 -0800/));
+ // default not present
+ test.ok(!response.message.match(/^Date:\s*[0-9\s:a-yA-Y]+\s+GMT$/m));
+ test.done();
+ })
+ },
"Use In-Reply-To": function(test){
var transport = nodemailer.createTransport("Stub"),

0 comments on commit 67ab6b2

Please sign in to comment.