nodemailer 6.5.0 → 6.6.0
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/CHANGELOG.md +5 -0
- package/lib/mail-composer/index.js +17 -9
- package/lib/mime-node/index.js +17 -0
- package/lib/{sendmail-transport → mime-node}/le-unix.js +0 -0
- package/lib/{sendmail-transport → mime-node}/le-windows.js +0 -0
- package/lib/sendmail-transport/index.js +2 -8
- package/lib/ses-transport/index.js +25 -17
- package/lib/shared/index.js +5 -1
- package/lib/stream-transport/index.js +1 -8
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -31,7 +31,7 @@ class MailComposer {
|
|
|
31
31
|
|
|
32
32
|
// Compose MIME tree
|
|
33
33
|
if (this.mail.raw) {
|
|
34
|
-
this.message = new MimeNode().setRaw(this.mail.raw);
|
|
34
|
+
this.message = new MimeNode('message/rfc822', { newline: this.mail.newline }).setRaw(this.mail.raw);
|
|
35
35
|
} else if (this._useMixed) {
|
|
36
36
|
this.message = this._createMixed();
|
|
37
37
|
} else if (this._useAlternative) {
|
|
@@ -345,13 +345,15 @@ class MailComposer {
|
|
|
345
345
|
boundaryPrefix: this.mail.boundaryPrefix,
|
|
346
346
|
disableUrlAccess: this.mail.disableUrlAccess,
|
|
347
347
|
disableFileAccess: this.mail.disableFileAccess,
|
|
348
|
-
normalizeHeaderKey: this.mail.normalizeHeaderKey
|
|
348
|
+
normalizeHeaderKey: this.mail.normalizeHeaderKey,
|
|
349
|
+
newline: this.mail.newline
|
|
349
350
|
});
|
|
350
351
|
} else {
|
|
351
352
|
node = parentNode.createChild('multipart/mixed', {
|
|
352
353
|
disableUrlAccess: this.mail.disableUrlAccess,
|
|
353
354
|
disableFileAccess: this.mail.disableFileAccess,
|
|
354
|
-
normalizeHeaderKey: this.mail.normalizeHeaderKey
|
|
355
|
+
normalizeHeaderKey: this.mail.normalizeHeaderKey,
|
|
356
|
+
newline: this.mail.newline
|
|
355
357
|
});
|
|
356
358
|
}
|
|
357
359
|
|
|
@@ -391,13 +393,15 @@ class MailComposer {
|
|
|
391
393
|
boundaryPrefix: this.mail.boundaryPrefix,
|
|
392
394
|
disableUrlAccess: this.mail.disableUrlAccess,
|
|
393
395
|
disableFileAccess: this.mail.disableFileAccess,
|
|
394
|
-
normalizeHeaderKey: this.mail.normalizeHeaderKey
|
|
396
|
+
normalizeHeaderKey: this.mail.normalizeHeaderKey,
|
|
397
|
+
newline: this.mail.newline
|
|
395
398
|
});
|
|
396
399
|
} else {
|
|
397
400
|
node = parentNode.createChild('multipart/alternative', {
|
|
398
401
|
disableUrlAccess: this.mail.disableUrlAccess,
|
|
399
402
|
disableFileAccess: this.mail.disableFileAccess,
|
|
400
|
-
normalizeHeaderKey: this.mail.normalizeHeaderKey
|
|
403
|
+
normalizeHeaderKey: this.mail.normalizeHeaderKey,
|
|
404
|
+
newline: this.mail.newline
|
|
401
405
|
});
|
|
402
406
|
}
|
|
403
407
|
|
|
@@ -428,13 +432,15 @@ class MailComposer {
|
|
|
428
432
|
boundaryPrefix: this.mail.boundaryPrefix,
|
|
429
433
|
disableUrlAccess: this.mail.disableUrlAccess,
|
|
430
434
|
disableFileAccess: this.mail.disableFileAccess,
|
|
431
|
-
normalizeHeaderKey: this.mail.normalizeHeaderKey
|
|
435
|
+
normalizeHeaderKey: this.mail.normalizeHeaderKey,
|
|
436
|
+
newline: this.mail.newline
|
|
432
437
|
});
|
|
433
438
|
} else {
|
|
434
439
|
node = parentNode.createChild('multipart/related; type="text/html"', {
|
|
435
440
|
disableUrlAccess: this.mail.disableUrlAccess,
|
|
436
441
|
disableFileAccess: this.mail.disableFileAccess,
|
|
437
|
-
normalizeHeaderKey: this.mail.normalizeHeaderKey
|
|
442
|
+
normalizeHeaderKey: this.mail.normalizeHeaderKey,
|
|
443
|
+
newline: this.mail.newline
|
|
438
444
|
});
|
|
439
445
|
}
|
|
440
446
|
|
|
@@ -470,7 +476,8 @@ class MailComposer {
|
|
|
470
476
|
boundaryPrefix: this.mail.boundaryPrefix,
|
|
471
477
|
disableUrlAccess: this.mail.disableUrlAccess,
|
|
472
478
|
disableFileAccess: this.mail.disableFileAccess,
|
|
473
|
-
normalizeHeaderKey: this.mail.normalizeHeaderKey
|
|
479
|
+
normalizeHeaderKey: this.mail.normalizeHeaderKey,
|
|
480
|
+
newline: this.mail.newline
|
|
474
481
|
});
|
|
475
482
|
} else {
|
|
476
483
|
node = parentNode.createChild(element.contentType, {
|
|
@@ -478,7 +485,8 @@ class MailComposer {
|
|
|
478
485
|
textEncoding: this.mail.textEncoding,
|
|
479
486
|
disableUrlAccess: this.mail.disableUrlAccess,
|
|
480
487
|
disableFileAccess: this.mail.disableFileAccess,
|
|
481
|
-
normalizeHeaderKey: this.mail.normalizeHeaderKey
|
|
488
|
+
normalizeHeaderKey: this.mail.normalizeHeaderKey,
|
|
489
|
+
newline: this.mail.newline
|
|
482
490
|
});
|
|
483
491
|
}
|
|
484
492
|
|
package/lib/mime-node/index.js
CHANGED
|
@@ -16,6 +16,9 @@ const addressparser = require('../addressparser');
|
|
|
16
16
|
const fetch = require('../fetch');
|
|
17
17
|
const LastNewline = require('./last-newline');
|
|
18
18
|
|
|
19
|
+
const LeWindows = require('./le-windows');
|
|
20
|
+
const LeUnix = require('./le-unix');
|
|
21
|
+
|
|
19
22
|
/**
|
|
20
23
|
* Creates a new mime tree node. Assumes 'multipart/*' as the content type
|
|
21
24
|
* if it is a branch, anything else counts as leaf. If rootNode is missing from
|
|
@@ -92,6 +95,11 @@ class MimeNode {
|
|
|
92
95
|
*/
|
|
93
96
|
this.hostname = options.hostname;
|
|
94
97
|
|
|
98
|
+
/**
|
|
99
|
+
* If set to 'win' then uses \r\n, if 'linux' then \n. If not set (or `raw` is used) then newlines are kept as is.
|
|
100
|
+
*/
|
|
101
|
+
this.newline = options.newline;
|
|
102
|
+
|
|
95
103
|
/**
|
|
96
104
|
* An array for possible child nodes
|
|
97
105
|
*/
|
|
@@ -626,6 +634,15 @@ class MimeNode {
|
|
|
626
634
|
outputStream = transform(outputStream);
|
|
627
635
|
}
|
|
628
636
|
|
|
637
|
+
if (this.newline) {
|
|
638
|
+
const winbreak = ['win', 'windows', 'dos', '\r\n'].includes(this.newline.toString().toLowerCase());
|
|
639
|
+
const newlineTransform = winbreak ? new LeWindows() : new LeUnix();
|
|
640
|
+
|
|
641
|
+
const stream = outputStream.pipe(newlineTransform);
|
|
642
|
+
outputStream.on('error', err => stream.emit('error', err));
|
|
643
|
+
return stream;
|
|
644
|
+
}
|
|
645
|
+
|
|
629
646
|
return outputStream;
|
|
630
647
|
}
|
|
631
648
|
|
|
File without changes
|
|
File without changes
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
const spawn = require('child_process').spawn;
|
|
4
4
|
const packageData = require('../../package.json');
|
|
5
|
-
const LeWindows = require('./le-windows');
|
|
6
|
-
const LeUnix = require('./le-unix');
|
|
7
5
|
const shared = require('../shared');
|
|
8
6
|
|
|
9
7
|
/**
|
|
@@ -68,7 +66,6 @@ class SendmailTransport {
|
|
|
68
66
|
let args;
|
|
69
67
|
let sendmail;
|
|
70
68
|
let returned;
|
|
71
|
-
let transform;
|
|
72
69
|
|
|
73
70
|
const hasInvalidAddresses = []
|
|
74
71
|
.concat(envelope.from || [])
|
|
@@ -187,10 +184,8 @@ class SendmailTransport {
|
|
|
187
184
|
recipients.join(', ')
|
|
188
185
|
);
|
|
189
186
|
|
|
190
|
-
transform = this.winbreak ? new LeWindows() : new LeUnix();
|
|
191
187
|
let sourceStream = mail.message.createReadStream();
|
|
192
|
-
|
|
193
|
-
transform.once('error', err => {
|
|
188
|
+
sourceStream.once('error', err => {
|
|
194
189
|
this.logger.error(
|
|
195
190
|
{
|
|
196
191
|
err,
|
|
@@ -205,8 +200,7 @@ class SendmailTransport {
|
|
|
205
200
|
callback(err);
|
|
206
201
|
});
|
|
207
202
|
|
|
208
|
-
sourceStream.
|
|
209
|
-
sourceStream.pipe(transform).pipe(sendmail.stdin);
|
|
203
|
+
sourceStream.pipe(sendmail.stdin);
|
|
210
204
|
} else {
|
|
211
205
|
return callback(new Error('sendmail was not found'));
|
|
212
206
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const EventEmitter = require('events');
|
|
4
4
|
const packageData = require('../../package.json');
|
|
5
5
|
const shared = require('../shared');
|
|
6
|
-
const LeWindows = require('../
|
|
6
|
+
const LeWindows = require('../mime-node/le-windows');
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Generates a Transport object for AWS SES
|
|
@@ -309,6 +309,23 @@ class SESTransport extends EventEmitter {
|
|
|
309
309
|
*/
|
|
310
310
|
verify(callback) {
|
|
311
311
|
let promise;
|
|
312
|
+
let ses = (this.ses.aws ? this.ses.ses : this.ses) || {};
|
|
313
|
+
let aws = this.ses.aws || {};
|
|
314
|
+
|
|
315
|
+
const sesMessage = {
|
|
316
|
+
RawMessage: {
|
|
317
|
+
// required
|
|
318
|
+
Data: 'From: invalid@invalid\r\nTo: invalid@invalid\r\n Subject: Invalid\r\n\r\nInvalid'
|
|
319
|
+
},
|
|
320
|
+
Source: 'invalid@invalid',
|
|
321
|
+
Destinations: ['invalid@invalid']
|
|
322
|
+
};
|
|
323
|
+
const cb = err => {
|
|
324
|
+
if (err && err.code !== 'InvalidParameterValue') {
|
|
325
|
+
return callback(err);
|
|
326
|
+
}
|
|
327
|
+
return callback(null, true);
|
|
328
|
+
};
|
|
312
329
|
|
|
313
330
|
if (!callback) {
|
|
314
331
|
promise = new Promise((resolve, reject) => {
|
|
@@ -316,22 +333,13 @@ class SESTransport extends EventEmitter {
|
|
|
316
333
|
});
|
|
317
334
|
}
|
|
318
335
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
Destinations: ['invalid@invalid']
|
|
327
|
-
},
|
|
328
|
-
err => {
|
|
329
|
-
if (err && err.code !== 'InvalidParameterValue') {
|
|
330
|
-
return callback(err);
|
|
331
|
-
}
|
|
332
|
-
return callback(null, true);
|
|
333
|
-
}
|
|
334
|
-
);
|
|
336
|
+
if (typeof ses.send === 'function' && aws.SendRawEmailCommand) {
|
|
337
|
+
// v3 API
|
|
338
|
+
ses.send(new aws.SendRawEmailCommand(sesMessage), cb);
|
|
339
|
+
} else {
|
|
340
|
+
// v2 API
|
|
341
|
+
ses.sendRawEmail(sesMessage, cb).promise();
|
|
342
|
+
}
|
|
335
343
|
|
|
336
344
|
return promise;
|
|
337
345
|
}
|
package/lib/shared/index.js
CHANGED
|
@@ -327,7 +327,11 @@ module.exports.resolveContent = (data, key, callback) => {
|
|
|
327
327
|
}
|
|
328
328
|
// we can't stream twice the same content, so we need
|
|
329
329
|
// to replace the stream object with the streaming result
|
|
330
|
-
data[key]
|
|
330
|
+
if (data[key].content) {
|
|
331
|
+
data[key].content = value;
|
|
332
|
+
} else {
|
|
333
|
+
data[key] = value;
|
|
334
|
+
}
|
|
331
335
|
callback(null, value);
|
|
332
336
|
});
|
|
333
337
|
} else if (/^https?:\/\//i.test(content.path || content.href)) {
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
const packageData = require('../../package.json');
|
|
4
4
|
const shared = require('../shared');
|
|
5
|
-
const LeWindows = require('../sendmail-transport/le-windows');
|
|
6
|
-
const LeUnix = require('../sendmail-transport/le-unix');
|
|
7
5
|
|
|
8
6
|
/**
|
|
9
7
|
* Generates a Transport object for streaming
|
|
@@ -61,15 +59,10 @@ class StreamTransport {
|
|
|
61
59
|
);
|
|
62
60
|
|
|
63
61
|
setImmediate(() => {
|
|
64
|
-
let sourceStream;
|
|
65
62
|
let stream;
|
|
66
|
-
let transform;
|
|
67
63
|
|
|
68
64
|
try {
|
|
69
|
-
|
|
70
|
-
sourceStream = mail.message.createReadStream();
|
|
71
|
-
stream = sourceStream.pipe(transform);
|
|
72
|
-
sourceStream.on('error', err => stream.emit('error', err));
|
|
65
|
+
stream = mail.message.createReadStream();
|
|
73
66
|
} catch (E) {
|
|
74
67
|
this.logger.error(
|
|
75
68
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nodemailer",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.6.0",
|
|
4
4
|
"description": "Easy as cake e-mail sending from your Node.js applications",
|
|
5
5
|
"main": "lib/nodemailer.js",
|
|
6
6
|
"scripts": {
|
|
@@ -21,21 +21,21 @@
|
|
|
21
21
|
"homepage": "https://nodemailer.com/",
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"bunyan": "1.8.15",
|
|
24
|
-
"chai": "4.3.
|
|
24
|
+
"chai": "4.3.4",
|
|
25
25
|
"eslint-config-nodemailer": "1.2.0",
|
|
26
|
-
"eslint-config-prettier": "8.
|
|
27
|
-
"grunt": "1.
|
|
28
|
-
"grunt-cli": "1.
|
|
26
|
+
"eslint-config-prettier": "8.3.0",
|
|
27
|
+
"grunt": "1.4.0",
|
|
28
|
+
"grunt-cli": "1.4.2",
|
|
29
29
|
"grunt-eslint": "23.0.0",
|
|
30
30
|
"grunt-mocha-test": "0.13.3",
|
|
31
31
|
"libbase64": "1.2.1",
|
|
32
32
|
"libmime": "5.0.0",
|
|
33
33
|
"libqp": "1.1.0",
|
|
34
|
-
"mocha": "8.3.
|
|
34
|
+
"mocha": "8.3.2",
|
|
35
35
|
"nodemailer-ntlm-auth": "1.0.1",
|
|
36
36
|
"proxy": "1.0.2",
|
|
37
37
|
"proxy-test-server": "1.0.0",
|
|
38
|
-
"sinon": "
|
|
38
|
+
"sinon": "10.0.0",
|
|
39
39
|
"smtp-server": "3.8.0"
|
|
40
40
|
},
|
|
41
41
|
"engines": {
|