Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added 'messageId' value to response data

  • Loading branch information...
commit 2db72fbe25c9c5f3d4983c2a07d73198d9b7a004 1 parent 01b5d8a
@andris9 authored
View
2  README.md
@@ -667,6 +667,7 @@ Return callback gets two parameters
* **error** - an error object if the message failed
* **responseStatus** - an object with some information about the status on success
+ * **responseStatus.messageId** - message ID used with the message
Example:
@@ -674,6 +675,7 @@ Example:
nodemailer.sendMail(mailOptions, function(error, responseStatus){
if(!error){
console.log(responseStatus.message); // response from the server
+ console.log(responseStatus.messageId); // Message-ID value used
}
});
```
View
2  lib/engines/sendmail.js
@@ -40,7 +40,7 @@ SendmailTransport.prototype.sendMail = function(emailMessage, callback) {
sendmail.on('exit', function (code) {
var msg = "Sendmail exited with "+code;
if(typeof callback == "function"){
- callback(code?new Error(msg):null, {message: msg});
+ callback(code?new Error(msg):null, {message: msg, messageId: emailMessage._messageId});
}
});
View
6 lib/engines/ses.js
@@ -109,7 +109,7 @@ SESTransport.prototype.handleMessage = function(email, callback) {
* @param {Object} response HTTP Response object
*/
SESTransport.prototype.responseHandler = function(callback, response) {
- var body = "";
+ var body = "", match;
response.setEncoding('utf8');
//Re-assembles response data
@@ -129,9 +129,11 @@ SESTransport.prototype.responseHandler = function(callback, response) {
response: response
});
}
+ match = (body || "").toString().match(/<MessageId\b[^>]*>([^<]+)<\/MessageId\b[^>]*>/i);
return typeof callback == "function" && callback(null, {
message: body,
- response: response
+ response: response,
+ messageId: match && match[1] && match[1] + "@email.amazonses.com"
});
});
};
View
15 lib/nodemailer.js
@@ -183,7 +183,7 @@ Nodemailer.prototype.sendMail = function(callback){
// compose the e-mail
this.generateMailObject();
// send the message using preselected transport method
- this.transport.sendMailWithTransport(this.mailcomposer, callback);
+ this.transport.sendMailWithTransport(this.mailcomposer, callback);
};
/**
@@ -261,6 +261,7 @@ Nodemailer.prototype.setUserHeaders = function(){
* <p>Add some required headers to the message, such as Date: and Message-Id:</p>
*/
Nodemailer.prototype.setModuleHeaders = function(){
+ var messageId;
// Mailer name + version
this.mailcomposer.addHeader("X-Mailer", this.generateUserAgentString());
@@ -274,12 +275,16 @@ Nodemailer.prototype.setModuleHeaders = function(){
// Message ID
if(this.options.messageId){
- this.mailcomposer.addHeader("Message-Id", "<"+this.options.messageId+">");
+ messageId = this.options.messageId;
}else if(this.options.messageId !== false){
- this.mailcomposer.addHeader("Message-Id", "<"+
- Date.now()+Math.random().toString(16).substr(1)+"@"+
- X_MAILER_NAME+">");
+ messageId = Date.now()+Math.random().toString(16).substr(1) +"@"+ X_MAILER_NAME;
}
+
+ if(messageId){
+ this.mailcomposer.addHeader("Message-Id", "<"+messageId+">");
+ this.mailcomposer._messageId = messageId;
+ }
+
};
/**
View
4 package.json
@@ -1,7 +1,7 @@
{
"name": "nodemailer",
"description": "Easy to use module to send e-mails, supports unicode and SSL/TLS",
- "version": "0.3.36",
+ "version": "0.3.37",
"author" : "Andris Reinman",
"maintainers":[
{
@@ -26,7 +26,7 @@
],
"dependencies": {
"mailcomposer": ">= 0.1.27",
- "simplesmtp": ">= 0.1.22",
+ "simplesmtp": ">= 0.1.28",
"optimist": "*"
},
"devDependencies": {
Please sign in to comment.
Something went wrong with that request. Please try again.