@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.
Files changed (47) hide show
  1. package/.gitattributes +6 -0
  2. package/.ncurc.js +9 -0
  3. package/.prettierignore +8 -0
  4. package/.prettierrc +12 -0
  5. package/.prettierrc.js +10 -0
  6. package/.release-please-config.json +9 -0
  7. package/CHANGELOG.md +929 -0
  8. package/CODE_OF_CONDUCT.md +76 -0
  9. package/LICENSE +16 -0
  10. package/README.md +86 -0
  11. package/SECURITY.txt +22 -0
  12. package/eslint.config.js +88 -0
  13. package/lib/addressparser/index.js +383 -0
  14. package/lib/base64/index.js +139 -0
  15. package/lib/dkim/index.js +253 -0
  16. package/lib/dkim/message-parser.js +155 -0
  17. package/lib/dkim/relaxed-body.js +154 -0
  18. package/lib/dkim/sign.js +117 -0
  19. package/lib/fetch/cookies.js +281 -0
  20. package/lib/fetch/index.js +280 -0
  21. package/lib/json-transport/index.js +82 -0
  22. package/lib/mail-composer/index.js +629 -0
  23. package/lib/mailer/index.js +441 -0
  24. package/lib/mailer/mail-message.js +316 -0
  25. package/lib/mime-funcs/index.js +625 -0
  26. package/lib/mime-funcs/mime-types.js +2113 -0
  27. package/lib/mime-node/index.js +1316 -0
  28. package/lib/mime-node/last-newline.js +33 -0
  29. package/lib/mime-node/le-unix.js +43 -0
  30. package/lib/mime-node/le-windows.js +52 -0
  31. package/lib/nodemailer.js +157 -0
  32. package/lib/punycode/index.js +460 -0
  33. package/lib/qp/index.js +227 -0
  34. package/lib/sendmail-transport/index.js +210 -0
  35. package/lib/ses-transport/index.js +234 -0
  36. package/lib/shared/index.js +754 -0
  37. package/lib/smtp-connection/data-stream.js +108 -0
  38. package/lib/smtp-connection/http-proxy-client.js +143 -0
  39. package/lib/smtp-connection/index.js +1865 -0
  40. package/lib/smtp-pool/index.js +652 -0
  41. package/lib/smtp-pool/pool-resource.js +259 -0
  42. package/lib/smtp-transport/index.js +421 -0
  43. package/lib/stream-transport/index.js +135 -0
  44. package/lib/well-known/index.js +47 -0
  45. package/lib/well-known/services.json +611 -0
  46. package/lib/xoauth2/index.js +427 -0
  47. 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
+ };