@depup/nodemailer 7.0.12-depup.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/.gitattributes +6 -0
- package/.ncurc.js +9 -0
- package/.prettierignore +8 -0
- package/.prettierrc +12 -0
- package/.prettierrc.js +10 -0
- package/.release-please-config.json +9 -0
- package/CHANGELOG.md +929 -0
- package/CODE_OF_CONDUCT.md +76 -0
- package/LICENSE +16 -0
- package/README.md +86 -0
- package/SECURITY.txt +22 -0
- package/eslint.config.js +88 -0
- package/lib/addressparser/index.js +383 -0
- package/lib/base64/index.js +139 -0
- package/lib/dkim/index.js +253 -0
- package/lib/dkim/message-parser.js +155 -0
- package/lib/dkim/relaxed-body.js +154 -0
- package/lib/dkim/sign.js +117 -0
- package/lib/fetch/cookies.js +281 -0
- package/lib/fetch/index.js +280 -0
- package/lib/json-transport/index.js +82 -0
- package/lib/mail-composer/index.js +629 -0
- package/lib/mailer/index.js +441 -0
- package/lib/mailer/mail-message.js +316 -0
- package/lib/mime-funcs/index.js +625 -0
- package/lib/mime-funcs/mime-types.js +2113 -0
- package/lib/mime-node/index.js +1316 -0
- package/lib/mime-node/last-newline.js +33 -0
- package/lib/mime-node/le-unix.js +43 -0
- package/lib/mime-node/le-windows.js +52 -0
- package/lib/nodemailer.js +157 -0
- package/lib/punycode/index.js +460 -0
- package/lib/qp/index.js +227 -0
- package/lib/sendmail-transport/index.js +210 -0
- package/lib/ses-transport/index.js +234 -0
- package/lib/shared/index.js +754 -0
- package/lib/smtp-connection/data-stream.js +108 -0
- package/lib/smtp-connection/http-proxy-client.js +143 -0
- package/lib/smtp-connection/index.js +1865 -0
- package/lib/smtp-pool/index.js +652 -0
- package/lib/smtp-pool/pool-resource.js +259 -0
- package/lib/smtp-transport/index.js +421 -0
- package/lib/stream-transport/index.js +135 -0
- package/lib/well-known/index.js +47 -0
- package/lib/well-known/services.json +611 -0
- package/lib/xoauth2/index.js +427 -0
- package/package.json +47 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const packageData = require('../../package.json');
|
|
4
|
+
const shared = require('../shared');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Generates a Transport object for streaming
|
|
8
|
+
*
|
|
9
|
+
* Possible options can be the following:
|
|
10
|
+
*
|
|
11
|
+
* * **buffer** if true, then returns the message as a Buffer object instead of a stream
|
|
12
|
+
* * **newline** either 'windows' or 'unix'
|
|
13
|
+
*
|
|
14
|
+
* @constructor
|
|
15
|
+
* @param {Object} optional config parameter
|
|
16
|
+
*/
|
|
17
|
+
class StreamTransport {
|
|
18
|
+
constructor(options) {
|
|
19
|
+
options = options || {};
|
|
20
|
+
|
|
21
|
+
this.options = options || {};
|
|
22
|
+
|
|
23
|
+
this.name = 'StreamTransport';
|
|
24
|
+
this.version = packageData.version;
|
|
25
|
+
|
|
26
|
+
this.logger = shared.getLogger(this.options, {
|
|
27
|
+
component: this.options.component || 'stream-transport'
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
this.winbreak = ['win', 'windows', 'dos', '\r\n'].includes((options.newline || '').toString().toLowerCase());
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Compiles a mailcomposer message and forwards it to handler that sends it
|
|
35
|
+
*
|
|
36
|
+
* @param {Object} emailMessage MailComposer object
|
|
37
|
+
* @param {Function} callback Callback function to run when the sending is completed
|
|
38
|
+
*/
|
|
39
|
+
send(mail, done) {
|
|
40
|
+
// We probably need this in the output
|
|
41
|
+
mail.message.keepBcc = true;
|
|
42
|
+
|
|
43
|
+
let envelope = mail.data.envelope || mail.message.getEnvelope();
|
|
44
|
+
let messageId = mail.message.messageId();
|
|
45
|
+
|
|
46
|
+
let recipients = [].concat(envelope.to || []);
|
|
47
|
+
if (recipients.length > 3) {
|
|
48
|
+
recipients.push('...and ' + recipients.splice(2).length + ' more');
|
|
49
|
+
}
|
|
50
|
+
this.logger.info(
|
|
51
|
+
{
|
|
52
|
+
tnx: 'send',
|
|
53
|
+
messageId
|
|
54
|
+
},
|
|
55
|
+
'Sending message %s to <%s> using %s line breaks',
|
|
56
|
+
messageId,
|
|
57
|
+
recipients.join(', '),
|
|
58
|
+
this.winbreak ? '<CR><LF>' : '<LF>'
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
setImmediate(() => {
|
|
62
|
+
let stream;
|
|
63
|
+
|
|
64
|
+
try {
|
|
65
|
+
stream = mail.message.createReadStream();
|
|
66
|
+
} catch (E) {
|
|
67
|
+
this.logger.error(
|
|
68
|
+
{
|
|
69
|
+
err: E,
|
|
70
|
+
tnx: 'send',
|
|
71
|
+
messageId
|
|
72
|
+
},
|
|
73
|
+
'Creating send stream failed for %s. %s',
|
|
74
|
+
messageId,
|
|
75
|
+
E.message
|
|
76
|
+
);
|
|
77
|
+
return done(E);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (!this.options.buffer) {
|
|
81
|
+
stream.once('error', err => {
|
|
82
|
+
this.logger.error(
|
|
83
|
+
{
|
|
84
|
+
err,
|
|
85
|
+
tnx: 'send',
|
|
86
|
+
messageId
|
|
87
|
+
},
|
|
88
|
+
'Failed creating message for %s. %s',
|
|
89
|
+
messageId,
|
|
90
|
+
err.message
|
|
91
|
+
);
|
|
92
|
+
});
|
|
93
|
+
return done(null, {
|
|
94
|
+
envelope: mail.data.envelope || mail.message.getEnvelope(),
|
|
95
|
+
messageId,
|
|
96
|
+
message: stream
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
let chunks = [];
|
|
101
|
+
let chunklen = 0;
|
|
102
|
+
stream.on('readable', () => {
|
|
103
|
+
let chunk;
|
|
104
|
+
while ((chunk = stream.read()) !== null) {
|
|
105
|
+
chunks.push(chunk);
|
|
106
|
+
chunklen += chunk.length;
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
stream.once('error', err => {
|
|
111
|
+
this.logger.error(
|
|
112
|
+
{
|
|
113
|
+
err,
|
|
114
|
+
tnx: 'send',
|
|
115
|
+
messageId
|
|
116
|
+
},
|
|
117
|
+
'Failed creating message for %s. %s',
|
|
118
|
+
messageId,
|
|
119
|
+
err.message
|
|
120
|
+
);
|
|
121
|
+
return done(err);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
stream.on('end', () =>
|
|
125
|
+
done(null, {
|
|
126
|
+
envelope: mail.data.envelope || mail.message.getEnvelope(),
|
|
127
|
+
messageId,
|
|
128
|
+
message: Buffer.concat(chunks, chunklen)
|
|
129
|
+
})
|
|
130
|
+
);
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
module.exports = StreamTransport;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const services = require('./services.json');
|
|
4
|
+
const normalized = {};
|
|
5
|
+
|
|
6
|
+
Object.keys(services).forEach(key => {
|
|
7
|
+
let service = services[key];
|
|
8
|
+
|
|
9
|
+
normalized[normalizeKey(key)] = normalizeService(service);
|
|
10
|
+
|
|
11
|
+
[].concat(service.aliases || []).forEach(alias => {
|
|
12
|
+
normalized[normalizeKey(alias)] = normalizeService(service);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
[].concat(service.domains || []).forEach(domain => {
|
|
16
|
+
normalized[normalizeKey(domain)] = normalizeService(service);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
function normalizeKey(key) {
|
|
21
|
+
return key.replace(/[^a-zA-Z0-9.-]/g, '').toLowerCase();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function normalizeService(service) {
|
|
25
|
+
let filter = ['domains', 'aliases'];
|
|
26
|
+
let response = {};
|
|
27
|
+
|
|
28
|
+
Object.keys(service).forEach(key => {
|
|
29
|
+
if (filter.indexOf(key) < 0) {
|
|
30
|
+
response[key] = service[key];
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
return response;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Resolves SMTP config for given key. Key can be a name (like 'Gmail'), alias (like 'Google Mail') or
|
|
39
|
+
* an email address (like 'test@googlemail.com').
|
|
40
|
+
*
|
|
41
|
+
* @param {String} key [description]
|
|
42
|
+
* @returns {Object} SMTP config or false if not found
|
|
43
|
+
*/
|
|
44
|
+
module.exports = function (key) {
|
|
45
|
+
key = normalizeKey(key.split('@').pop());
|
|
46
|
+
return normalized[key] || false;
|
|
47
|
+
};
|