nodemailer 9.1.0 → 10.0.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 (172) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/README.md +8 -4
  3. package/SECURITY.md +7 -7
  4. package/dist/cjs/addressparser/index.d.ts +47 -0
  5. package/dist/cjs/addressparser/index.js +508 -0
  6. package/dist/cjs/base64/index.d.ts +40 -0
  7. package/{lib → dist/cjs}/base64/index.js +31 -53
  8. package/dist/cjs/dkim/index.d.ts +40 -0
  9. package/dist/cjs/dkim/index.js +211 -0
  10. package/dist/cjs/dkim/message-parser.d.ts +41 -0
  11. package/dist/cjs/dkim/message-parser.js +147 -0
  12. package/dist/cjs/dkim/relaxed-body.d.ts +46 -0
  13. package/dist/cjs/dkim/relaxed-body.js +143 -0
  14. package/dist/cjs/dkim/sign.d.ts +49 -0
  15. package/dist/cjs/dkim/sign.js +148 -0
  16. package/dist/cjs/errors.d.ts +95 -0
  17. package/dist/cjs/errors.js +70 -0
  18. package/dist/cjs/fetch/cookies.d.ts +94 -0
  19. package/dist/cjs/fetch/cookies.js +268 -0
  20. package/dist/cjs/fetch/index.d.ts +51 -0
  21. package/dist/cjs/fetch/index.js +409 -0
  22. package/dist/cjs/json-transport/index.d.ts +54 -0
  23. package/dist/cjs/json-transport/index.js +97 -0
  24. package/dist/cjs/mail-composer/index.d.ts +224 -0
  25. package/dist/cjs/mail-composer/index.js +602 -0
  26. package/dist/cjs/mailer/index.d.ts +226 -0
  27. package/dist/cjs/mailer/index.js +401 -0
  28. package/dist/cjs/mailer/mail-message.d.ts +94 -0
  29. package/dist/cjs/mailer/mail-message.js +339 -0
  30. package/dist/cjs/mime-funcs/index.d.ts +157 -0
  31. package/dist/cjs/mime-funcs/index.js +670 -0
  32. package/dist/cjs/mime-funcs/mime-types.d.ts +2 -0
  33. package/dist/cjs/mime-funcs/mime-types.js +2103 -0
  34. package/dist/cjs/mime-node/index.d.ts +484 -0
  35. package/dist/cjs/mime-node/index.js +1422 -0
  36. package/dist/cjs/mime-node/last-newline.d.ts +7 -0
  37. package/dist/cjs/mime-node/last-newline.js +30 -0
  38. package/dist/cjs/mime-node/le-unix.d.ts +13 -0
  39. package/dist/cjs/mime-node/le-unix.js +39 -0
  40. package/dist/cjs/mime-node/le-windows.d.ts +14 -0
  41. package/dist/cjs/mime-node/le-windows.js +46 -0
  42. package/dist/cjs/nodemailer.d.ts +102 -0
  43. package/dist/cjs/nodemailer.js +207 -0
  44. package/dist/cjs/package-info.d.ts +3 -0
  45. package/dist/cjs/package-info.js +7 -0
  46. package/dist/cjs/package.json +3 -0
  47. package/dist/cjs/punycode/index.d.ts +73 -0
  48. package/{lib → dist/cjs}/punycode/index.js +61 -111
  49. package/dist/cjs/qp/index.d.ts +33 -0
  50. package/{lib → dist/cjs}/qp/index.js +30 -64
  51. package/dist/cjs/sendmail-transport/index.d.ts +69 -0
  52. package/dist/cjs/sendmail-transport/index.js +210 -0
  53. package/dist/cjs/ses-transport/index.d.ts +75 -0
  54. package/dist/cjs/ses-transport/index.js +248 -0
  55. package/dist/cjs/shared/index.d.ts +230 -0
  56. package/dist/cjs/shared/index.js +665 -0
  57. package/dist/cjs/shared/objects.d.ts +23 -0
  58. package/dist/cjs/shared/objects.js +43 -0
  59. package/dist/cjs/shared/url.d.ts +21 -0
  60. package/dist/cjs/shared/url.js +255 -0
  61. package/dist/cjs/smtp-connection/data-stream.d.ts +22 -0
  62. package/dist/cjs/smtp-connection/data-stream.js +98 -0
  63. package/dist/cjs/smtp-connection/http-proxy-client.d.ts +39 -0
  64. package/dist/cjs/smtp-connection/http-proxy-client.js +177 -0
  65. package/dist/cjs/smtp-connection/index.d.ts +719 -0
  66. package/dist/cjs/smtp-connection/index.js +1676 -0
  67. package/dist/cjs/smtp-pool/index.d.ts +163 -0
  68. package/dist/cjs/smtp-pool/index.js +530 -0
  69. package/dist/cjs/smtp-pool/pool-resource.d.ts +64 -0
  70. package/dist/cjs/smtp-pool/pool-resource.js +261 -0
  71. package/dist/cjs/smtp-transport/index.d.ts +143 -0
  72. package/dist/cjs/smtp-transport/index.js +379 -0
  73. package/dist/cjs/stream-transport/index.d.ts +63 -0
  74. package/dist/cjs/stream-transport/index.js +146 -0
  75. package/dist/cjs/well-known/index.d.ts +35 -0
  76. package/dist/cjs/well-known/index.js +41 -0
  77. package/dist/cjs/well-known/services.d.ts +2 -0
  78. package/dist/cjs/well-known/services.js +666 -0
  79. package/dist/cjs/xoauth2/index.d.ts +191 -0
  80. package/dist/cjs/xoauth2/index.js +414 -0
  81. package/dist/esm/addressparser/index.d.ts +47 -0
  82. package/{lib → dist/esm}/addressparser/index.js +49 -102
  83. package/dist/esm/base64/index.d.ts +40 -0
  84. package/dist/esm/base64/index.js +110 -0
  85. package/dist/esm/dkim/index.d.ts +40 -0
  86. package/{lib → dist/esm}/dkim/index.js +24 -70
  87. package/dist/esm/dkim/message-parser.d.ts +41 -0
  88. package/{lib → dist/esm}/dkim/message-parser.js +28 -40
  89. package/dist/esm/dkim/relaxed-body.d.ts +46 -0
  90. package/dist/esm/dkim/relaxed-body.js +135 -0
  91. package/dist/esm/dkim/sign.d.ts +49 -0
  92. package/{lib → dist/esm}/dkim/sign.js +32 -45
  93. package/dist/esm/errors.d.ts +95 -0
  94. package/{lib → dist/esm}/errors.js +26 -18
  95. package/dist/esm/fetch/cookies.d.ts +94 -0
  96. package/{lib → dist/esm}/fetch/cookies.js +75 -121
  97. package/dist/esm/fetch/index.d.ts +51 -0
  98. package/{lib → dist/esm}/fetch/index.js +46 -88
  99. package/dist/esm/json-transport/index.d.ts +54 -0
  100. package/{lib → dist/esm}/json-transport/index.js +17 -39
  101. package/dist/esm/mail-composer/index.d.ts +224 -0
  102. package/{lib → dist/esm}/mail-composer/index.js +187 -264
  103. package/dist/esm/mailer/index.d.ts +226 -0
  104. package/{lib → dist/esm}/mailer/index.js +109 -229
  105. package/dist/esm/mailer/mail-message.d.ts +94 -0
  106. package/{lib → dist/esm}/mailer/mail-message.js +84 -113
  107. package/dist/esm/mime-funcs/index.d.ts +157 -0
  108. package/dist/esm/mime-funcs/index.js +621 -0
  109. package/dist/esm/mime-funcs/mime-types.d.ts +2 -0
  110. package/{lib → dist/esm}/mime-funcs/mime-types.js +29 -42
  111. package/dist/esm/mime-node/index.d.ts +484 -0
  112. package/{lib → dist/esm}/mime-node/index.js +203 -359
  113. package/dist/esm/mime-node/last-newline.d.ts +7 -0
  114. package/{lib → dist/esm}/mime-node/last-newline.js +2 -10
  115. package/dist/esm/mime-node/le-unix.d.ts +13 -0
  116. package/{lib → dist/esm}/mime-node/le-unix.js +5 -11
  117. package/dist/esm/mime-node/le-windows.d.ts +14 -0
  118. package/{lib → dist/esm}/mime-node/le-windows.js +5 -13
  119. package/dist/esm/nodemailer.d.ts +102 -0
  120. package/{lib → dist/esm}/nodemailer.js +65 -69
  121. package/dist/esm/package-info.d.ts +3 -0
  122. package/dist/esm/package-info.js +4 -0
  123. package/dist/esm/package.json +3 -0
  124. package/dist/esm/punycode/index.d.ts +73 -0
  125. package/dist/esm/punycode/index.js +404 -0
  126. package/dist/esm/qp/index.d.ts +33 -0
  127. package/dist/esm/qp/index.js +190 -0
  128. package/dist/esm/sendmail-transport/index.d.ts +69 -0
  129. package/{lib → dist/esm}/sendmail-transport/index.js +51 -101
  130. package/dist/esm/ses-transport/index.d.ts +75 -0
  131. package/dist/esm/ses-transport/index.js +208 -0
  132. package/dist/esm/shared/index.d.ts +230 -0
  133. package/{lib → dist/esm}/shared/index.js +137 -268
  134. package/dist/esm/shared/objects.d.ts +23 -0
  135. package/{lib → dist/esm}/shared/objects.js +13 -17
  136. package/dist/esm/shared/url.d.ts +21 -0
  137. package/dist/esm/shared/url.js +214 -0
  138. package/dist/esm/smtp-connection/data-stream.d.ts +22 -0
  139. package/{lib → dist/esm}/smtp-connection/data-stream.js +14 -26
  140. package/dist/esm/smtp-connection/http-proxy-client.d.ts +39 -0
  141. package/{lib → dist/esm}/smtp-connection/http-proxy-client.js +27 -64
  142. package/dist/esm/smtp-connection/index.d.ts +719 -0
  143. package/{lib → dist/esm}/smtp-connection/index.js +332 -713
  144. package/dist/esm/smtp-pool/index.d.ts +163 -0
  145. package/{lib → dist/esm}/smtp-pool/index.js +120 -271
  146. package/dist/esm/smtp-pool/pool-resource.d.ts +64 -0
  147. package/{lib → dist/esm}/smtp-pool/pool-resource.js +36 -72
  148. package/dist/esm/smtp-transport/index.d.ts +143 -0
  149. package/{lib → dist/esm}/smtp-transport/index.js +58 -148
  150. package/dist/esm/stream-transport/index.d.ts +63 -0
  151. package/{lib → dist/esm}/stream-transport/index.js +36 -74
  152. package/dist/esm/well-known/index.d.ts +35 -0
  153. package/{lib → dist/esm}/well-known/index.js +5 -16
  154. package/dist/esm/well-known/services.d.ts +2 -0
  155. package/dist/esm/well-known/services.js +663 -0
  156. package/dist/esm/xoauth2/index.d.ts +191 -0
  157. package/{lib → dist/esm}/xoauth2/index.js +101 -175
  158. package/package.json +139 -14
  159. package/.gitattributes +0 -6
  160. package/.ncurc.js +0 -9
  161. package/.prettierignore +0 -8
  162. package/.prettierrc +0 -12
  163. package/.prettierrc.js +0 -10
  164. package/.release-please-config.json +0 -9
  165. package/CLAUDE.md +0 -56
  166. package/CODE_OF_CONDUCT.md +0 -76
  167. package/eslint.config.js +0 -88
  168. package/lib/dkim/relaxed-body.js +0 -154
  169. package/lib/mime-funcs/index.js +0 -671
  170. package/lib/ses-transport/index.js +0 -266
  171. package/lib/shared/url.js +0 -151
  172. /package/{lib → dist}/well-known/services.json +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,40 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## [10.0.0](https://github.com/nodemailer/nodemailer/compare/v9.1.1...v10.0.0) (2026-09-03)
4
+
5
+
6
+ ### ⚠ BREAKING CHANGES
7
+
8
+ * Node.js 20 or newer is required. The Node.js 6 syntax compatibility check and the .npmignore file are gone.
9
+
10
+ ### Features
11
+
12
+ * keep the @types/nodemailer type layout working ([1cc5356](https://github.com/nodemailer/nodemailer/commit/1cc535627e1bb672214b09fa4cc503567275fd7f))
13
+ * migrate to TypeScript with ES module and CommonJS builds ([f7cbf83](https://github.com/nodemailer/nodemailer/commit/f7cbf8384e0ea6055efcc514afb8bc070ac3a2b1))
14
+
15
+
16
+ ### Bug Fixes
17
+
18
+ * apply the other keys of a configuration object next to its url ([29610f9](https://github.com/nodemailer/nodemailer/commit/29610f9fe04dbd8af04c4a3362f3b68d293592da))
19
+ * **dkim:** canonicalize raw messages the way verifiers do ([2c84b11](https://github.com/nodemailer/nodemailer/commit/2c84b117d4d138751e9ffa8607f3796771bb5e66))
20
+ * keep a transporter assignable to the plain Transporter type ([8bf55fb](https://github.com/nodemailer/nodemailer/commit/8bf55fb177cf155b24d6bb86a7cd86670146d551))
21
+ * **shared:** keep a colon in the user name of a connection or proxy url ([6acf4b6](https://github.com/nodemailer/nodemailer/commit/6acf4b67d919971f516f58940113c9b8598b2254))
22
+ * **shared:** refuse URL hosts the legacy parser would truncate ([17a5068](https://github.com/nodemailer/nodemailer/commit/17a5068f06e62fc04e1d5545ed70d4248bef258e))
23
+ * **shared:** resolve hostnames when the runtime has no interface table ([8b03240](https://github.com/nodemailer/nodemailer/commit/8b032407135ea05ae377e623a7021705a4a139d0))
24
+ * **smtp-connection:** clear the timers of a connection dropped before the greeting ([01dcaa0](https://github.com/nodemailer/nodemailer/commit/01dcaa05b212aafc33747041027fb8c66497e0eb))
25
+ * **smtp-connection:** keep an incomplete server reply out of lastServerResponse ([1a6e427](https://github.com/nodemailer/nodemailer/commit/1a6e4271adb808509adf11832ad1adfdfc05c31b))
26
+ * **smtp-pool:** free the pool slot when the proxy socket can not be opened ([204a344](https://github.com/nodemailer/nodemailer/commit/204a344f7e4068ff41385195ee394a223ebadd84))
27
+ * **well-known:** keep nodemailer/lib/well-known/services.json available ([367730c](https://github.com/nodemailer/nodemailer/commit/367730cce85bc78c7804405c2cc7d89d93aafdd1))
28
+
29
+ ## [9.1.1](https://github.com/nodemailer/nodemailer/compare/v9.1.0...v9.1.1) (2026-09-01)
30
+
31
+
32
+ ### Bug Fixes
33
+
34
+ * **mailer:** apply the message access policy in resolveContent ([dc48ed3](https://github.com/nodemailer/nodemailer/commit/dc48ed395c4d6c79ee5c95eb6eff17bafe391474))
35
+ * **mailer:** keep message data from reopening the access sandbox ([ab7ef34](https://github.com/nodemailer/nodemailer/commit/ab7ef348b9a97b1fd70e7bfbeb56d4ea4a07946b))
36
+ * **mime-node:** inherit the access policy from the tree a node hangs in ([262d550](https://github.com/nodemailer/nodemailer/commit/262d550b1e121e3ff4ef6675d6771a5b2b4ddcec))
37
+
3
38
  ## [9.1.0](https://github.com/nodemailer/nodemailer/compare/v9.0.6...v9.1.0) (2026-08-31)
4
39
 
5
40
 
package/README.md CHANGED
@@ -10,15 +10,19 @@ See [nodemailer.com](https://nodemailer.com/) for documentation and terms.
10
10
 
11
11
  > Nodemailer is developed by the team behind **[EmailEngine](https://emailengine.app/?utm_source=nodemailer-readme&utm_medium=readme&utm_campaign=oss-docs)**, a self-hosted email API that turns any Gmail, Microsoft 365, or IMAP account into a REST endpoint, with managed OAuth2, webhooks for incoming mail, and built-in [sending](https://emailengine.app/sending-emails?utm_source=nodemailer-readme&utm_medium=readme&utm_campaign=oss-docs). If you would rather call an HTTP API than maintain IMAP and SMTP connections yourself, that is what it is for.
12
12
 
13
+ ## Supported runtimes
14
+
15
+ Nodemailer targets Node.js 20 and later. The ES module build also runs on [Bun](https://bun.sh/) (tested against the latest release) and on [Cloudflare Workers](https://developers.cloudflare.com/workers/) with the `nodejs_compat` compatibility flag. On Workers only the SMTP based transports apply, `sendmail` needs a child process, and the runtime does not allow turning certificate validation off, so `tls.rejectUnauthorized: false` fails there with an error.
16
+
13
17
  ## Having an issue?
14
18
 
15
19
  #### First review the docs
16
20
 
17
21
  Documentation for Nodemailer can be found at [nodemailer.com](https://nodemailer.com/about/).
18
22
 
19
- #### Nodemailer throws a SyntaxError for "..."
23
+ #### Nodemailer fails to load or throws a SyntaxError
20
24
 
21
- You are using an older Node.js version than v6.0. Upgrade Node.js to get support for the spread operator. Nodemailer supports all Node.js versions starting from Node.js@v6.0.0.
25
+ Nodemailer 10 and later require Node.js 20 or newer. The package ships both ES module and CommonJS builds, so `import nodemailer from 'nodemailer'` and `const nodemailer = require('nodemailer')` both work. If you need to run on an older Node.js version, stay on the 9.x line.
22
26
 
23
27
  #### I'm having issues with Gmail
24
28
 
@@ -52,7 +56,7 @@ let configOptions = {
52
56
 
53
57
  #### I have issues with DNS / hosts file
54
58
 
55
- Node.js uses [c-ares](https://nodejs.org/en/docs/meta/topics/dependencies/#c-ares) to resolve domain names, not the DNS library provided by the system, so if you have some custom DNS routing set up, it might be ignored. Nodemailer runs [dns.resolve4()](https://nodejs.org/dist/latest-v16.x/docs/api/dns.html#dnsresolve4hostname-options-callback) and [dns.resolve6()](https://nodejs.org/dist/latest-v16.x/docs/api/dns.html#dnsresolve6hostname-options-callback) to resolve hostname into an IP address. If both calls fail, then Nodemailer will fall back to [dns.lookup()](https://nodejs.org/dist/latest-v16.x/docs/api/dns.html#dnslookuphostname-options-callback). If this does not work for you, you can hard code the IP address into the configuration like shown below. In that case, Nodemailer would not perform any DNS lookups.
59
+ Node.js uses [c-ares](https://github.com/c-ares/c-ares) to resolve domain names, not the DNS library provided by the system, so if you have some custom DNS routing set up, it might be ignored. Nodemailer runs [dns.resolve4()](https://nodejs.org/dist/latest-v16.x/docs/api/dns.html#dnsresolve4hostname-options-callback) and [dns.resolve6()](https://nodejs.org/dist/latest-v16.x/docs/api/dns.html#dnsresolve6hostname-options-callback) to resolve hostname into an IP address. If both calls fail, then Nodemailer will fall back to [dns.lookup()](https://nodejs.org/dist/latest-v16.x/docs/api/dns.html#dnslookuphostname-options-callback). If this does not work for you, you can hard code the IP address into the configuration like shown below. In that case, Nodemailer would not perform any DNS lookups.
56
60
 
57
61
  ```js
58
62
  let configOptions = {
@@ -68,7 +72,7 @@ let configOptions = {
68
72
 
69
73
  #### I have an issue with TypeScript types
70
74
 
71
- Nodemailer has official support for Node.js only. For anything related to TypeScript, you need to directly contact the authors of the [type definitions](https://www.npmjs.com/package/@types/nodemailer).
75
+ Nodemailer 10 and later are written in TypeScript and ship their own type definitions, so `@types/nodemailer` is no longer needed and should be removed from your project to avoid conflicting declarations. The type names follow the layout of the old definitions, so references such as `Mail.Options`, `SMTPTransport.Options` or `Transporter<SMTPTransport.SentMessageInfo>` keep compiling, and the most used types (`SendMailOptions`, `Transporter`, `SentMessageInfo`, `Attachment`, `Address`) are exported from the package root. For older Nodemailer versions, the community maintained [type definitions](https://www.npmjs.com/package/@types/nodemailer) still apply.
72
76
 
73
77
  #### I have a different problem
74
78
 
package/SECURITY.md CHANGED
@@ -6,13 +6,13 @@ reports seriously and aim to respond quickly.
6
6
  ## Supported Versions
7
7
 
8
8
  Security fixes are released only against the latest major version. We do not
9
- backport patches to older majors upgrading to the current release line is the
10
- supported way to receive security updates.
9
+ backport patches to older majors, so upgrading to the current release line is
10
+ the supported way to receive security updates.
11
11
 
12
12
  | Version | Supported |
13
13
  | ------- | ------------------ |
14
- | 8.x | :white_check_mark: |
15
- | < 8.0 | :x: |
14
+ | 10.x | :white_check_mark: |
15
+ | < 10.0 | :x: |
16
16
 
17
17
  If you are on an older major, please upgrade. See the migration notes at
18
18
  <https://nodemailer.com/> before updating.
@@ -41,7 +41,7 @@ When reporting, please include as much of the following as you can:
41
41
  - Any suggested remediation, if you have one.
42
42
 
43
43
  Nodemailer is maintained by a single person, so there is no guaranteed response
44
- time sometimes reports are handled within hours, sometimes they take longer.
44
+ time: sometimes reports are handled within hours, sometimes they take longer.
45
45
  Accepted issues are fixed in a new release and coordinated through a GitHub
46
46
  Security Advisory, and reporters who wish to be named are credited.
47
47
 
@@ -49,12 +49,12 @@ Security Advisory, and reporters who wish to be named are credited.
49
49
 
50
50
  We track and disclose vulnerabilities through GitHub Security Advisories. We do
51
51
  not request or manage CVE identifiers ourselves. If you need a CVE assigned for a
52
- reported issue, please request one yourself for example, through GitHub's own
52
+ reported issue, please request one yourself, for example through GitHub's own
53
53
  CVE request flow on the published advisory, or another CNA.
54
54
 
55
55
  ## Scope
56
56
 
57
- In scope: the `nodemailer` package source in this repository message and MIME
57
+ In scope: the `nodemailer` package source in this repository: message and MIME
58
58
  generation, SMTP/LMTP client behaviour, address parsing, header handling, DKIM
59
59
  signing, and the bundled transports.
60
60
 
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Options for addressparser
3
+ */
4
+ export interface AddressParserOptions {
5
+ /** Flatten groups into a single list of mailboxes */
6
+ flatten?: boolean;
7
+ /** Internal recursion depth counter (do not set manually) */
8
+ _depth?: number;
9
+ }
10
+ /**
11
+ * A single mailbox. Either value may be an empty string when the input did not carry it
12
+ */
13
+ export interface MailboxAddress {
14
+ name: string;
15
+ address: string;
16
+ group?: undefined;
17
+ }
18
+ /**
19
+ * An address group. RFC 5322 does not allow nested groups, so any nesting is flattened
20
+ * into `group`
21
+ */
22
+ export interface GroupAddress {
23
+ name: string;
24
+ group: Address[];
25
+ address?: undefined;
26
+ }
27
+ /**
28
+ * A parsed address entry, either a mailbox or a group
29
+ */
30
+ export type Address = MailboxAddress | GroupAddress;
31
+ /**
32
+ * Parses structured e-mail addresses from an address field
33
+ *
34
+ * Example:
35
+ *
36
+ * 'Name <address@domain>'
37
+ *
38
+ * will be converted to
39
+ *
40
+ * [{name: 'Name', address: 'address@domain'}]
41
+ *
42
+ * @param str Address field
43
+ * @param options Optional options object
44
+ * @param options._depth Internal recursion depth counter (do not set manually)
45
+ * @return An array of address objects
46
+ */
47
+ export default function addressparser(str?: string | null, options?: AddressParserOptions): Address[];