nodemailer 5.1.1 → 6.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.DS_Store +0 -0
- package/CHANGELOG.md +17 -0
- package/lib/.DS_Store +0 -0
- package/lib/addressparser/index.js +18 -1
- package/lib/mail-composer/index.js +13 -0
- package/lib/mailer/index.js +1 -1
- package/lib/mailer/mail-message.js +2 -2
- package/lib/smtp-connection/index.js +27 -20
- package/lib/smtp-pool/pool-resource.js +1 -1
- package/lib/smtp-transport/index.js +1 -1
- package/lib/well-known/services.json +1 -4
- package/package.json +6 -6
package/.DS_Store
ADDED
|
Binary file
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## 6.2.0 2019-05-24
|
|
4
|
+
|
|
5
|
+
- Added new option for addressparser: `flatten`. If true then ignores group names and returns a single list of all addresses
|
|
6
|
+
|
|
7
|
+
## 6.1.1 2019-04-20
|
|
8
|
+
|
|
9
|
+
- Fixed regression bug with missing smtp `authMethod` property
|
|
10
|
+
|
|
11
|
+
## 6.1.0 2019-04-06
|
|
12
|
+
|
|
13
|
+
- Added new message property `amp` for providing AMP4EMAIL content
|
|
14
|
+
|
|
15
|
+
## 6.0.0 2019-03-25
|
|
16
|
+
|
|
17
|
+
- SMTPConnection: use removeListener instead of removeAllListeners (xr0master) [ddc4af15]
|
|
18
|
+
Using removeListener should fix memory leak with Node.js streams
|
|
19
|
+
|
|
3
20
|
## 5.1.1 2019-01-09
|
|
4
21
|
|
|
5
22
|
- Added missing option argument for custom auth
|
package/lib/.DS_Store
ADDED
|
Binary file
|
|
@@ -255,7 +255,9 @@ class Tokenizer {
|
|
|
255
255
|
* @param {String} str Address field
|
|
256
256
|
* @return {Array} An array of address objects
|
|
257
257
|
*/
|
|
258
|
-
function addressparser(str) {
|
|
258
|
+
function addressparser(str, options) {
|
|
259
|
+
options = options || {};
|
|
260
|
+
|
|
259
261
|
let tokenizer = new Tokenizer(str);
|
|
260
262
|
let tokens = tokenizer.tokenize();
|
|
261
263
|
|
|
@@ -285,6 +287,21 @@ function addressparser(str) {
|
|
|
285
287
|
}
|
|
286
288
|
});
|
|
287
289
|
|
|
290
|
+
if (options.flatten) {
|
|
291
|
+
let addresses = [];
|
|
292
|
+
let walkAddressList = list => {
|
|
293
|
+
list.forEach(address => {
|
|
294
|
+
if (address.group) {
|
|
295
|
+
return walkAddressList(address.group);
|
|
296
|
+
} else {
|
|
297
|
+
addresses.push(address);
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
};
|
|
301
|
+
walkAddressList(parsedAddresses);
|
|
302
|
+
return addresses;
|
|
303
|
+
}
|
|
304
|
+
|
|
288
305
|
return parsedAddresses;
|
|
289
306
|
}
|
|
290
307
|
|
|
@@ -194,6 +194,7 @@ class MailComposer {
|
|
|
194
194
|
text,
|
|
195
195
|
html,
|
|
196
196
|
watchHtml,
|
|
197
|
+
amp,
|
|
197
198
|
icalEvent,
|
|
198
199
|
eventObject;
|
|
199
200
|
|
|
@@ -222,6 +223,17 @@ class MailComposer {
|
|
|
222
223
|
watchHtml.contentType = 'text/watch-html' + (!watchHtml.encoding && mimeFuncs.isPlainText(watchHtml.content) ? '' : '; charset=utf-8');
|
|
223
224
|
}
|
|
224
225
|
|
|
226
|
+
if (this.mail.amp) {
|
|
227
|
+
if (typeof this.mail.amp === 'object' && (this.mail.amp.content || this.mail.amp.path || this.mail.amp.href || this.mail.amp.raw)) {
|
|
228
|
+
amp = this.mail.amp;
|
|
229
|
+
} else {
|
|
230
|
+
amp = {
|
|
231
|
+
content: this.mail.amp
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
amp.contentType = 'text/x-amp-html' + (!amp.encoding && mimeFuncs.isPlainText(amp.content) ? '' : '; charset=utf-8');
|
|
235
|
+
}
|
|
236
|
+
|
|
225
237
|
// only include the calendar alternative if there are no attachments
|
|
226
238
|
// otherwise you might end up in a blank screen on some clients
|
|
227
239
|
if (this.mail.icalEvent && !(this.mail.attachments && this.mail.attachments.length)) {
|
|
@@ -273,6 +285,7 @@ class MailComposer {
|
|
|
273
285
|
[]
|
|
274
286
|
.concat(text || [])
|
|
275
287
|
.concat(watchHtml || [])
|
|
288
|
+
.concat(amp || [])
|
|
276
289
|
.concat(html || [])
|
|
277
290
|
.concat(eventObject || [])
|
|
278
291
|
.concat(this.mail.alternatives || [])
|
package/lib/mailer/index.js
CHANGED
|
@@ -57,7 +57,7 @@ class Mail extends EventEmitter {
|
|
|
57
57
|
);
|
|
58
58
|
|
|
59
59
|
// setup emit handlers for the transporter
|
|
60
|
-
if (typeof transporter.on === 'function') {
|
|
60
|
+
if (typeof this.transporter.on === 'function') {
|
|
61
61
|
// deprecated log interface
|
|
62
62
|
this.transporter.on('log', log => {
|
|
63
63
|
this.logger.debug(
|
|
@@ -47,7 +47,7 @@ class MailMessage {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
resolveAll(callback) {
|
|
50
|
-
let keys = [[this.data, 'html'], [this.data, 'text'], [this.data, 'watchHtml'], [this.data, 'icalEvent']];
|
|
50
|
+
let keys = [[this.data, 'html'], [this.data, 'text'], [this.data, 'watchHtml'], [this.data, 'amp'], [this.data, 'icalEvent']];
|
|
51
51
|
|
|
52
52
|
if (this.data.alternatives && this.data.alternatives.length) {
|
|
53
53
|
this.data.alternatives.forEach((alternative, i) => {
|
|
@@ -147,7 +147,7 @@ class MailMessage {
|
|
|
147
147
|
data.envelope = envelope;
|
|
148
148
|
data.messageId = messageId;
|
|
149
149
|
|
|
150
|
-
['html', 'text', 'watchHtml'].forEach(key => {
|
|
150
|
+
['html', 'text', 'watchHtml', 'amp'].forEach(key => {
|
|
151
151
|
if (data[key] && data[key].content) {
|
|
152
152
|
if (typeof data[key].content === 'string') {
|
|
153
153
|
data[key] = data[key].content;
|
|
@@ -182,6 +182,15 @@ class SMTPConnection extends EventEmitter {
|
|
|
182
182
|
* @private
|
|
183
183
|
*/
|
|
184
184
|
this._closing = false;
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Callbacks for socket's listeners
|
|
188
|
+
*/
|
|
189
|
+
this._onSocketData = (chunk) => this._onData(chunk);
|
|
190
|
+
this._onSocketError = (error) => this._onError(error, 'ESOCKET', false, 'CONN');
|
|
191
|
+
this._onSocketClose = () => this._onClose();
|
|
192
|
+
this._onSocketEnd = () => this._onEnd();
|
|
193
|
+
this._onSocketTimeout = () => this._onTimeout();
|
|
185
194
|
}
|
|
186
195
|
|
|
187
196
|
/**
|
|
@@ -220,9 +229,7 @@ class SMTPConnection extends EventEmitter {
|
|
|
220
229
|
this._onError('Connection timeout', 'ETIMEDOUT', false, 'CONN');
|
|
221
230
|
}, this.options.connectionTimeout || CONNECTION_TIMEOUT);
|
|
222
231
|
|
|
223
|
-
this._socket.on('error',
|
|
224
|
-
this._onError(err, 'ECONNECTION', false, 'CONN');
|
|
225
|
-
});
|
|
232
|
+
this._socket.on('error', this._onSocketError);
|
|
226
233
|
};
|
|
227
234
|
|
|
228
235
|
if (this.options.connection) {
|
|
@@ -683,17 +690,17 @@ class SMTPConnection extends EventEmitter {
|
|
|
683
690
|
this.stage = 'connected';
|
|
684
691
|
|
|
685
692
|
// clear existing listeners for the socket
|
|
686
|
-
this._socket.
|
|
687
|
-
this._socket.
|
|
688
|
-
this._socket.
|
|
689
|
-
this._socket.
|
|
693
|
+
this._socket.removeListener('data', this._onSocketData);
|
|
694
|
+
this._socket.removeListener('timeout', this._onSocketTimeout);
|
|
695
|
+
this._socket.removeListener('close', this._onSocketClose);
|
|
696
|
+
this._socket.removeListener('end', this._onSocketEnd);
|
|
690
697
|
|
|
691
|
-
this._socket.on('data',
|
|
692
|
-
this._socket.once('close',
|
|
693
|
-
this._socket.once('end',
|
|
698
|
+
this._socket.on('data', this._onSocketData);
|
|
699
|
+
this._socket.once('close', this._onSocketClose);
|
|
700
|
+
this._socket.once('end', this._onSocketEnd);
|
|
694
701
|
|
|
695
702
|
this._socket.setTimeout(this.options.socketTimeout || SOCKET_TIMEOUT);
|
|
696
|
-
this._socket.on('timeout',
|
|
703
|
+
this._socket.on('timeout', this._onSocketTimeout);
|
|
697
704
|
|
|
698
705
|
this._greetingTimeout = setTimeout(() => {
|
|
699
706
|
// if still waiting for greeting, give up
|
|
@@ -857,8 +864,8 @@ class SMTPConnection extends EventEmitter {
|
|
|
857
864
|
// apparently a 'finish' event set that would be cleared as well
|
|
858
865
|
|
|
859
866
|
// we can safely keep 'error', 'end', 'close' etc. events
|
|
860
|
-
this._socket.
|
|
861
|
-
this._socket.
|
|
867
|
+
this._socket.removeListener('data', this._onSocketData); // incoming data is going to be gibberish from this point onwards
|
|
868
|
+
this._socket.removeListener('timeout', this._onSocketTimeout); // timeout will be re-set for the new socket object
|
|
862
869
|
|
|
863
870
|
let socketPlain = this._socket;
|
|
864
871
|
let opts = {
|
|
@@ -876,21 +883,21 @@ class SMTPConnection extends EventEmitter {
|
|
|
876
883
|
() => {
|
|
877
884
|
this.secure = true;
|
|
878
885
|
this.upgrading = false;
|
|
879
|
-
this._socket.on('data',
|
|
886
|
+
this._socket.on('data', this._onSocketData);
|
|
880
887
|
|
|
881
|
-
socketPlain.
|
|
882
|
-
socketPlain.
|
|
888
|
+
socketPlain.removeListener('close', this._onSocketClose);
|
|
889
|
+
socketPlain.removeListener('end', this._onSocketEnd);
|
|
883
890
|
|
|
884
891
|
return callback(null, true);
|
|
885
892
|
}
|
|
886
893
|
);
|
|
887
894
|
|
|
888
|
-
this._socket.on('error',
|
|
889
|
-
this._socket.once('close',
|
|
890
|
-
this._socket.once('end',
|
|
895
|
+
this._socket.on('error', this._onSocketError);
|
|
896
|
+
this._socket.once('close', this._onSocketClose);
|
|
897
|
+
this._socket.once('end', this._onSocketEnd);
|
|
891
898
|
|
|
892
899
|
this._socket.setTimeout(this.options.socketTimeout || SOCKET_TIMEOUT); // 10 min.
|
|
893
|
-
this._socket.on('timeout',
|
|
900
|
+
this._socket.on('timeout', this._onSocketTimeout);
|
|
894
901
|
|
|
895
902
|
// resume in case the socket was paused
|
|
896
903
|
socketPlain.resume();
|
|
@@ -46,7 +46,7 @@ class PoolResource extends EventEmitter {
|
|
|
46
46
|
pass: this.options.auth.pass,
|
|
47
47
|
options: this.options.auth.options
|
|
48
48
|
},
|
|
49
|
-
method: (this.options.auth.method || '').trim().toUpperCase() || false
|
|
49
|
+
method: (this.options.auth.method || '').trim().toUpperCase() || this.options.authMethod || false
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
52
|
}
|
|
@@ -121,7 +121,7 @@ class SMTPTransport extends EventEmitter {
|
|
|
121
121
|
pass: authData.pass,
|
|
122
122
|
options: authData.options
|
|
123
123
|
},
|
|
124
|
-
method: (authData.method || '').trim().toUpperCase() || false
|
|
124
|
+
method: (authData.method || '').trim().toUpperCase() || this.options.authMethod || false
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
127
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nodemailer",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.2.1",
|
|
4
4
|
"description": "Easy as cake e-mail sending from your Node.js applications",
|
|
5
5
|
"main": "lib/nodemailer.js",
|
|
6
6
|
"scripts": {
|
|
@@ -23,19 +23,19 @@
|
|
|
23
23
|
"bunyan": "1.8.12",
|
|
24
24
|
"chai": "4.2.0",
|
|
25
25
|
"eslint-config-nodemailer": "1.2.0",
|
|
26
|
-
"eslint-config-prettier": "
|
|
27
|
-
"grunt": "1.0.
|
|
26
|
+
"eslint-config-prettier": "4.3.0",
|
|
27
|
+
"grunt": "1.0.4",
|
|
28
28
|
"grunt-cli": "1.3.2",
|
|
29
29
|
"grunt-eslint": "21.0.0",
|
|
30
30
|
"grunt-mocha-test": "0.13.3",
|
|
31
31
|
"libbase64": "1.0.3",
|
|
32
|
-
"libmime": "4.
|
|
32
|
+
"libmime": "4.1.3",
|
|
33
33
|
"libqp": "1.1.0",
|
|
34
|
-
"mocha": "
|
|
34
|
+
"mocha": "6.1.4",
|
|
35
35
|
"nodemailer-ntlm-auth": "1.0.1",
|
|
36
36
|
"proxy": "0.2.4",
|
|
37
37
|
"proxy-test-server": "1.0.0",
|
|
38
|
-
"sinon": "7.
|
|
38
|
+
"sinon": "7.3.2",
|
|
39
39
|
"smtp-server": "3.5.0"
|
|
40
40
|
},
|
|
41
41
|
"engines": {
|