nodemailer
Advanced tools
Comparing version 6.4.2 to 6.4.3
# CHANGELOG | ||
## 6.4.3 2020-02-22 | ||
- Added an option to specify max number of requeues when connection closes unexpectedly (Igor Sechyn) [8a927f5a] | ||
## 6.4.2 2019-12-11 | ||
@@ -4,0 +8,0 @@ |
@@ -106,2 +106,3 @@ 'use strict'; | ||
mail, | ||
requeueAttempts: 0, | ||
callback | ||
@@ -395,2 +396,3 @@ }); | ||
// If the connection closed when sending, add the message to the queue again | ||
// if max number of requeues is not reached yet | ||
// Note that we must wait a bit.. because the callback of the 'error' handler might be called | ||
@@ -400,15 +402,7 @@ // in the next event loop | ||
if (connection.queueEntry) { | ||
this.logger.debug( | ||
{ | ||
tnx: 'pool', | ||
cid: connection.id, | ||
messageId: connection.queueEntry.messageId, | ||
action: 'requeue' | ||
}, | ||
'Re-queued message <%s> for #%s', | ||
connection.queueEntry.messageId, | ||
connection.id | ||
); | ||
this._queue.unshift(connection.queueEntry); | ||
connection.queueEntry = false; | ||
if (this._shouldRequeuOnConnectionClose(connection.queueEntry)) { | ||
this._requeueEntryOnConnectionClose(connection); | ||
} else { | ||
this._failDeliveryOnConnectionClose(connection); | ||
} | ||
} | ||
@@ -427,2 +421,49 @@ this._continueProcessing(); | ||
_shouldRequeuOnConnectionClose(queueEntry) { | ||
if (this.options.maxRequeues === undefined || this.options.maxRequeues < 0) { | ||
return true; | ||
} | ||
return queueEntry.requeueAttempts && queueEntry.requeueAttempts < this.options.maxRequeues; | ||
} | ||
_failDeliveryOnConnectionClose(connection) { | ||
if (connection.queueEntry && connection.queueEntry.callback) { | ||
try { | ||
connection.queueEntry.callback(new Error('Reached maximum number of retries after connection was closed')); | ||
} catch (E) { | ||
this.logger.error( | ||
{ | ||
err: E, | ||
tnx: 'callback', | ||
messageId: connection.queueEntry.messageId, | ||
cid: connection.id | ||
}, | ||
'Callback error for #%s: %s', | ||
connection.id, | ||
E.message | ||
); | ||
} | ||
connection.queueEntry = false; | ||
} | ||
} | ||
_requeueEntryOnConnectionClose(connection) { | ||
connection.queueEntry.requeueAttempts = connection.queueEntry.requeueAttempts + 1; | ||
this.logger.debug( | ||
{ | ||
tnx: 'pool', | ||
cid: connection.id, | ||
messageId: connection.queueEntry.messageId, | ||
action: 'requeue' | ||
}, | ||
'Re-queued message <%s> for #%s. Attempt: #%s', | ||
connection.queueEntry.messageId, | ||
connection.id, | ||
connection.queueEntry.requeueAttempts | ||
); | ||
this._queue.unshift(connection.queueEntry); | ||
connection.queueEntry = false; | ||
} | ||
/** | ||
@@ -429,0 +470,0 @@ * Continue to process message if the pool hasn't closed |
{ | ||
"name": "nodemailer", | ||
"version": "6.4.2", | ||
"version": "6.4.3", | ||
"description": "Easy as cake e-mail sending from your Node.js applications", | ||
@@ -5,0 +5,0 @@ "main": "lib/nodemailer.js", |
@@ -11,6 +11,2 @@ # Nodemailer | ||
## Why version bump to 5? | ||
Nodemailer changed from `dns.lookup()` to `dns.resolve` for resolving SMTP hostnames which might be backwards incompatible and thus the version bump. Nodemailer tries first `resolve4()` and if no match is found then `resolve6()` and finally reverts back to `lookup()`. Additionally found DNS results are cached (for 5 minutes). This should make it easier to manage high performance clients that send a lot of messages in parallel. | ||
## Having an issue? | ||
@@ -28,3 +24,3 @@ | ||
Gmail either works well or it does not work at all. It is probably easier to switch to an alternative service instead of fixing issues with Gmail. If Gmail does not work for you then don't use it. | ||
Gmail either works well or it does not work at all. It is probably easier to switch to an alternative service instead of fixing issues with Gmail. If Gmail does not work for you then don't use it. Read more about it [here](https://nodemailer.com/usage/using-gmail/). | ||
@@ -37,3 +33,4 @@ #### I get ETIMEDOUT errors | ||
If you are running the code in your own machine, then check your antivirus settings. Antiviruses often mess around with email ports usage. Node.js might not recognize the MITM cert your antivirus is using. | ||
* If you are running the code in your own machine, then check your antivirus settings. Antiviruses often mess around with email ports usage. Node.js might not recognize the MITM cert your antivirus is using. | ||
* Latest Node versions allow only TLS versions 1.2 and higher, some servers might still use TLS 1.1 or lower. Check Node.js docs how to get correct TLS support for your app. | ||
@@ -40,0 +37,0 @@ #### I have a different problem |
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
461887
11329
45