emailengine-app 2.79.7 → 2.79.9

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 (188) hide show
  1. package/.github/dependabot.yml +22 -0
  2. package/.github/workflows/test.yml +39 -0
  3. package/.release-please-manifest.json +1 -1
  4. package/CHANGELOG.md +37 -0
  5. package/DOCKER_DEPLOYMENT.md +8 -7
  6. package/Dockerfile +35 -11
  7. package/bin/emailengine.js +29 -13
  8. package/config/default.toml +15 -4
  9. package/copy-static-files.sh +23 -5
  10. package/data/google-crawlers.json +7 -1
  11. package/docker-compose.yml +12 -3
  12. package/install.sh +2 -0
  13. package/lib/account.js +26 -1
  14. package/lib/api-routes/account-routes.js +14 -3
  15. package/lib/api-routes/bull-board-routes.js +3 -2
  16. package/lib/api-routes/mailbox-routes.js +4 -1
  17. package/lib/api-routes/message-routes.js +6 -5
  18. package/lib/api-routes/outbox-routes.js +7 -4
  19. package/lib/api-routes/route-helpers.js +8 -0
  20. package/lib/api-routes/settings-routes.js +34 -25
  21. package/lib/api-routes/stats-routes.js +8 -1
  22. package/lib/api-routes/submit-routes.js +2 -1
  23. package/lib/api-routes/template-routes.js +3 -2
  24. package/lib/auth-token.js +73 -2
  25. package/lib/autodetect-imap-settings.js +33 -25
  26. package/lib/bounce-detect.js +45 -0
  27. package/lib/consts.js +13 -2
  28. package/lib/egress-fetch.js +133 -0
  29. package/lib/egress-filter.js +39 -4
  30. package/lib/email-client/base-client.js +274 -24
  31. package/lib/email-client/gmail/gmail-api.js +15 -7
  32. package/lib/email-client/gmail-client.js +121 -64
  33. package/lib/email-client/imap/mailbox.js +18 -59
  34. package/lib/email-client/imap-client.js +53 -29
  35. package/lib/email-client/notification-handler.js +11 -2
  36. package/lib/email-client/outlook/graph-api.js +106 -90
  37. package/lib/email-client/outlook-client.js +222 -106
  38. package/lib/export.js +35 -2
  39. package/lib/generate-text-preview.js +10 -5
  40. package/lib/handlebars-helpers.js +129 -0
  41. package/lib/headers-rewriter.js +1 -1
  42. package/lib/imap-proxy-auth.js +41 -21
  43. package/lib/imapproxy/imap-core/README.md +1 -0
  44. package/lib/imapproxy/imap-core/lib/tls-options.js +5 -46
  45. package/lib/imapproxy/imap-server.js +9 -10
  46. package/lib/llm-pre-process.js +4 -1
  47. package/lib/mcp/json-schema.js +50 -2
  48. package/lib/openapi/index.js +3 -0
  49. package/lib/outbox.js +50 -8
  50. package/lib/pre-process.js +4 -1
  51. package/lib/rate-limit.js +23 -4
  52. package/lib/rewrite-text-nodes.js +12 -1
  53. package/lib/schemas.js +37 -8
  54. package/lib/security-headers.js +396 -0
  55. package/lib/sentry.js +36 -4
  56. package/lib/settings.js +19 -1
  57. package/lib/smtp-auth.js +86 -7
  58. package/lib/sso.js +13 -3
  59. package/lib/submit-progress.js +29 -0
  60. package/lib/templates.js +11 -0
  61. package/lib/tools.js +361 -173
  62. package/lib/ui-routes/account-routes.js +73 -13
  63. package/lib/ui-routes/admin-config-routes.js +7 -21
  64. package/lib/ui-routes/admin-entities-routes.js +42 -12
  65. package/lib/ui-routes/auth-routes.js +87 -28
  66. package/lib/ui-routes/dashboard-routes.js +1 -1
  67. package/lib/ui-routes/export-routes.js +4 -0
  68. package/lib/ui-routes/internals-routes.js +2 -0
  69. package/lib/ui-routes/mcp-consent-routes.js +12 -2
  70. package/lib/ui-routes/network-config-routes.js +6 -5
  71. package/lib/ui-routes/oauth-config-routes.js +12 -1
  72. package/lib/ui-routes/route-helpers.js +65 -14
  73. package/lib/ui-routes/settings-page.js +10 -0
  74. package/lib/ui-routes/smtp-test-routes.js +7 -0
  75. package/lib/ui-routes/suppression-list-routes.js +16 -5
  76. package/lib/ui-routes/unsubscribe-routes.js +22 -3
  77. package/lib/webhook-egress.js +5 -0
  78. package/lib/webhooks.js +14 -2
  79. package/package.json +23 -26
  80. package/sbom.json +1 -1
  81. package/server.js +100 -71
  82. package/static/css/flyonui.css +1 -1
  83. package/static/js/ace/css/ace.css +1462 -0
  84. package/static/js/ace/css/kuroir-1.png +0 -0
  85. package/static/js/ace/css/kuroir-2.png +0 -0
  86. package/static/js/ace/css/main-1.png +0 -0
  87. package/static/js/ace/css/main-10.svg +4 -0
  88. package/static/js/ace/css/main-11.svg +5 -0
  89. package/static/js/ace/css/main-12.svg +4 -0
  90. package/static/js/ace/css/main-13.png +0 -0
  91. package/static/js/ace/css/main-14.png +0 -0
  92. package/static/js/ace/css/main-15.png +0 -0
  93. package/static/js/ace/css/main-16.png +0 -0
  94. package/static/js/ace/css/main-17.png +0 -0
  95. package/static/js/ace/css/main-18.png +0 -0
  96. package/static/js/ace/css/main-19.png +0 -0
  97. package/static/js/ace/css/main-2.png +0 -0
  98. package/static/js/ace/css/main-20.png +0 -0
  99. package/static/js/ace/css/main-21.png +0 -0
  100. package/static/js/ace/css/main-22.png +0 -0
  101. package/static/js/ace/css/main-23.png +0 -0
  102. package/static/js/ace/css/main-24.png +0 -0
  103. package/static/js/ace/css/main-25.svg +1 -0
  104. package/static/js/ace/css/main-26.png +0 -0
  105. package/static/js/ace/css/main-3.png +0 -0
  106. package/static/js/ace/css/main-4.png +0 -0
  107. package/static/js/ace/css/main-5.svg +7 -0
  108. package/static/js/ace/css/main-6.svg +9 -0
  109. package/static/js/ace/css/main-7.svg +7 -0
  110. package/static/js/ace/css/main-8.svg +9 -0
  111. package/static/js/ace/css/main-9.svg +6 -0
  112. package/static/js/ace/css/theme/kuroir.css +78 -0
  113. package/static/js/ace/css/theme/tomorrow_night.css +128 -0
  114. package/static/js/ace/css/theme/tomorrow_night_eighties.css +128 -0
  115. package/static/js/ace/css/theme/xcode.css +106 -0
  116. package/static/js/ace/css/tomorrow_night-1.png +0 -0
  117. package/static/js/ace/css/tomorrow_night-2.png +0 -0
  118. package/static/js/ace/css/tomorrow_night_eighties-1.png +0 -0
  119. package/static/js/ace/css/tomorrow_night_eighties-2.png +0 -0
  120. package/static/js/ace/css/xcode-1.png +0 -0
  121. package/static/js/ace/css/xcode-2.png +0 -0
  122. package/static/js/ee-client.js +256 -102
  123. package/static/js/public.js +7 -0
  124. package/static/js/ui.js +32 -0
  125. package/static/licenses.html +338 -298
  126. package/static/vendor/simplewebauthn/browser.min.js +2 -2
  127. package/translations/messages.pot +158 -112
  128. package/views/account/passkeys.hbs +8 -0
  129. package/views/account/password.hbs +11 -0
  130. package/views/account/security.hbs +18 -7
  131. package/views/accounts/account.hbs +21 -38
  132. package/views/accounts/browse.hbs +3 -1
  133. package/views/accounts/edit.hbs +1 -1
  134. package/views/accounts/register/imap-server.hbs +11 -3
  135. package/views/config/ai.hbs +3 -1
  136. package/views/config/branding.hbs +4 -2
  137. package/views/config/document-store/chat.hbs +1 -1
  138. package/views/config/document-store/index.hbs +1 -1
  139. package/views/config/email-processing.hbs +2 -0
  140. package/views/config/imap-proxy.hbs +3 -1
  141. package/views/config/license.hbs +1 -1
  142. package/views/config/logging.hbs +3 -1
  143. package/views/config/mcp.hbs +3 -1
  144. package/views/config/network.hbs +16 -16
  145. package/views/config/oauth/app.hbs +4 -4
  146. package/views/config/security.hbs +2 -0
  147. package/views/config/service.hbs +3 -1
  148. package/views/config/smtp.hbs +3 -1
  149. package/views/config/webhooks.hbs +4 -2
  150. package/views/error.hbs +10 -2
  151. package/views/internals/index.hbs +1 -1
  152. package/views/layout/app.hbs +9 -14
  153. package/views/layout/login.hbs +1 -1
  154. package/views/layout/prompt.hbs +1 -1
  155. package/views/layout/public.hbs +1 -1
  156. package/views/legal.hbs +1 -1
  157. package/views/mcp/authorize.hbs +1 -1
  158. package/views/partials/ace_assets.hbs +13 -0
  159. package/views/partials/add_account_modal.hbs +1 -1
  160. package/views/partials/address_list.hbs +4 -4
  161. package/views/partials/filter_editor_js.hbs +3 -3
  162. package/views/partials/gateway_js.hbs +1 -1
  163. package/views/partials/oauth_form.hbs +6 -6
  164. package/views/partials/public_theme_init.hbs +1 -1
  165. package/views/partials/template_form.hbs +2 -2
  166. package/views/partials/test_send.hbs +7 -4
  167. package/views/partials/theme_init.hbs +1 -1
  168. package/views/partials/ui/details.hbs +2 -2
  169. package/views/partials/ui/env-managed-alert.hbs +19 -0
  170. package/views/partials/webhook_form.hbs +1 -1
  171. package/views/partials/webhooks_editor_functions.hbs +1 -1
  172. package/views/reference/redirect.hbs +1 -1
  173. package/views/templates/template.hbs +2 -2
  174. package/views/tokens/new.hbs +1 -1
  175. package/views/unsubscribe.hbs +7 -1
  176. package/views/webhooks/webhook.hbs +2 -2
  177. package/workers/api.js +179 -175
  178. package/workers/export.js +1 -5
  179. package/workers/imap.js +33 -6
  180. package/workers/smtp.js +19 -43
  181. package/workers/submit.js +31 -13
  182. package/workers/webhooks.js +9 -24
  183. package/lib/reconnection-manager.js +0 -106
  184. package/static/front/EmailEngine_logo_horiz.png +0 -0
  185. package/static/front/EmailEngine_logo_vert.png +0 -0
  186. package/static/front/index.html +0 -57
  187. package/static/front/logo.png +0 -0
  188. package/static/vendor/handlebars/handlebars.min-v4.7.9.js +0 -29
@@ -0,0 +1,22 @@
1
+ version: 2
2
+
3
+ updates:
4
+ # The Node base image is the one dependency that goes stale without any diff to review, which is
5
+ # how it ended up 19 months behind. This entry exists to keep the digest current, nothing else.
6
+ - package-ecosystem: docker
7
+ directory: /
8
+ schedule:
9
+ interval: weekly
10
+ commit-message:
11
+ # `fix:` rather than `chore:`, so a base image bump reaches users through the release notes
12
+ # instead of being filtered out of them
13
+ prefix: fix
14
+ # Digest updates only. The Node major is a deliberate choice that has to stay in step with the
15
+ # CI matrix, the pkg targets and the deploy workflow, and it tracks Active LTS rather than
16
+ # Current - left unignored, the first run proposed 24-alpine to 26-alpine, which is exactly the
17
+ # drift this entry is meant to prevent. Moving the major is a manual decision.
18
+ ignore:
19
+ - dependency-name: node
20
+ update-types:
21
+ - version-update:semver-major
22
+ - version-update:semver-minor
@@ -135,6 +135,45 @@ jobs:
135
135
  #
136
136
  # One target, unsigned, uncompressed. Signing and notarization need Apple credentials and
137
137
  # stay on the release machine; neither has any bearing on whether the bundle can be built.
138
+ # The image ships an OS and a Node runtime we do not build, so its vulnerabilities arrive on
139
+ # someone else's schedule rather than in a diff. Nothing watched that before, and the base pin
140
+ # sat unmoved for 19 months while 21 Alpine CVEs accumulated behind it.
141
+ #
142
+ # Scoped to fixed HIGH/CRITICAL on purpose. An unfixed upstream CVE is not actionable here and
143
+ # would block unrelated work at random; once a fix exists, a rebuild picks it up through
144
+ # `apk upgrade`, or the base pin needs moving - both of which are on us.
145
+ docker_scan:
146
+ name: Docker Image Scan
147
+ if: ${{ !startsWith(github.ref_name, 'release-please--') && !startsWith(github.head_ref, 'release-please--') }}
148
+ runs-on: ubuntu-24.04
149
+ timeout-minutes: 20
150
+ steps:
151
+ - uses: actions/checkout@v6
152
+
153
+ # Single arch: the findings are properties of the base image and the lockfile, neither of
154
+ # which differs per architecture, so scanning both legs would only double the runtime.
155
+ - name: Build the image
156
+ uses: docker/build-push-action@v7
157
+ with:
158
+ context: .
159
+ platforms: linux/amd64
160
+ load: true
161
+ tags: emailengine:scan
162
+
163
+ - name: Scan for known vulnerabilities
164
+ uses: aquasecurity/trivy-action@v0.36.0
165
+ with:
166
+ image-ref: emailengine:scan
167
+ scanners: vuln
168
+ severity: HIGH,CRITICAL
169
+ ignore-unfixed: true
170
+ exit-code: '1'
171
+ format: table
172
+ env:
173
+ # Trivy pulls its database from ghcr.io and is rate limited unauthenticated
174
+ TRIVY_USERNAME: ${{ github.actor }}
175
+ TRIVY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
176
+
138
177
  pkg_build:
139
178
  name: Binary Build (linux-x64, unsigned)
140
179
  if: ${{ !startsWith(github.ref_name, 'release-please--') && !startsWith(github.head_ref, 'release-please--') }}
@@ -1,3 +1,3 @@
1
1
  {
2
- ".": "2.79.7"
2
+ ".": "2.79.9"
3
3
  }
package/CHANGELOG.md CHANGED
@@ -1,5 +1,42 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.79.9](https://github.com/postalsys/emailengine/compare/v2.79.8...v2.79.9) (2026-09-07)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **admin-ui:** remove the unreferenced static landing page ([eea5024](https://github.com/postalsys/emailengine/commit/eea5024e701d9633d1d19e14fc16f9512b73327f))
9
+ * **admin-ui:** render the delivery-test and address-list fragments server-side ([4443c32](https://github.com/postalsys/emailengine/commit/4443c3211c76548ac00041752b22ce52b4e6f479))
10
+ * **deps:** collapse the duplicate nodemailer copies onto version 10 ([661a2ed](https://github.com/postalsys/emailengine/commit/661a2ed29325e775ecdbd86861428e1bf26c45a4))
11
+ * **deps:** update dependencies ([2f32929](https://github.com/postalsys/emailengine/commit/2f32929fe2624a393516701aad48b41a13b78c8e))
12
+ * **deps:** update dependencies and collapse the duplicate nodemailer copies ([09553a3](https://github.com/postalsys/emailengine/commit/09553a35817b3da040eca8fa3795ed5b9dcf470a))
13
+ * **deps:** update dependencies and drop the message browser stylesheet exception ([1933e5d](https://github.com/postalsys/emailengine/commit/1933e5d9952fab26fbd3f4a630adfc0ca341717a))
14
+ * **deps:** update dependencies, picking up the dispatcher options of certs and email-ai-tools ([28ecf49](https://github.com/postalsys/emailengine/commit/28ecf499362d02bcfb7c7811e12757093e856667))
15
+ * **docker:** move the image to Node 24 and drop npm from the runtime layer ([ad190d3](https://github.com/postalsys/emailengine/commit/ad190d34972004216a612d25f32403054bd5639e))
16
+ * **proxy:** route every outbound HTTP request through the global proxy ([2ac1fb6](https://github.com/postalsys/emailengine/commit/2ac1fb65bb2db9143747cb160e4c3dc5e8b89086))
17
+ * refuse to start below Node 20, the floor package.json declares ([1bf24eb](https://github.com/postalsys/emailengine/commit/1bf24eb5988164236ced87f64a528b12ac9af9f3))
18
+ * **security:** require a nonce on stylesheets and tag the machine-facing routes ([cbcd4cb](https://github.com/postalsys/emailengine/commit/cbcd4cb16896aac91bce0c58feb112d809828cd5))
19
+ * **security:** send a nonce-based Content-Security-Policy and the remaining security headers ([4f2900e](https://github.com/postalsys/emailengine/commit/4f2900e5de6d6aeac2333d774ea3977793f99e22))
20
+ * **security:** vet autodiscovery egress, throttle proxy logins and add response headers ([74856cf](https://github.com/postalsys/emailengine/commit/74856cf64a0231ee7e38bbfb140639e29632aaa9))
21
+ * **submit:** drop an outbox entry that does not decode to a message ([e7e6618](https://github.com/postalsys/emailengine/commit/e7e6618ec31032c3d88c2bec3f89ffa70c13970d))
22
+
23
+ ## [2.79.8](https://github.com/postalsys/emailengine/compare/v2.79.7...v2.79.8) (2026-09-02)
24
+
25
+
26
+ ### Bug Fixes
27
+
28
+ * **admin-ui:** keep form input on a failed save and fix the misrouted webhook form ([e01d8a2](https://github.com/postalsys/emailengine/commit/e01d8a2021fde0e0122b5dc98a8f539128c8a4af))
29
+ * **api:** keep template formats on update and answer malformed ids with 4xx ([3eb9868](https://github.com/postalsys/emailengine/commit/3eb9868fd5f2639e1ad40a26ec2e7a91e308c2e3))
30
+ * **auth:** secure every API worker on the first password and tighten the admin second factor ([0adb3b4](https://github.com/postalsys/emailengine/commit/0adb3b46baf29d7125a81b9ec61a7e091b7826da))
31
+ * **config:** stop prepared configuration from surprising operators on restart ([0f4ab9a](https://github.com/postalsys/emailengine/commit/0f4ab9ab78e4fa4e648c9384c6d0a7fc8b80a937))
32
+ * **delivery:** treat delay notices as delays and unwrap embedded IPv4 in the egress filter ([37ccc5c](https://github.com/postalsys/emailengine/commit/37ccc5c2ccab1c5ca301fec482d2e09cb2c9b352))
33
+ * **deps:** update imapflow to 1.7.8 for the download teardown worker deaths ([18d68b2](https://github.com/postalsys/emailengine/commit/18d68b29893c20a59ccec91526e4e5a420e73c0d))
34
+ * **deps:** update nodemailer to 9.1.1 across the dependency tree ([e67641e](https://github.com/postalsys/emailengine/commit/e67641e54c655a4a71b61919ed4098deb908b2b5))
35
+ * **email-client:** close the gaps between the IMAP, Gmail and Graph clients ([47f4623](https://github.com/postalsys/emailengine/commit/47f4623ac0ef3f483fbebbb33d935e141f17d4b4))
36
+ * **submit:** do not send a message again when a stalled job is re-run ([91c7c00](https://github.com/postalsys/emailengine/commit/91c7c0045d858b987a18a92afd934afdf8b0f3d1))
37
+ * **tracking:** route a text-node decoder failure to the rewrite's rejection path ([13e9f9f](https://github.com/postalsys/emailengine/commit/13e9f9fd71a5933677adb428d17c77af3a0ee691))
38
+ * **webhooks:** send Basic-auth credentials verbatim and deliver each attempt once ([c6d1242](https://github.com/postalsys/emailengine/commit/c6d1242b737bc215d35284f70493afa064b8cde7))
39
+
3
40
  ## [2.79.7](https://github.com/postalsys/emailengine/compare/v2.79.6...v2.79.7) (2026-08-31)
4
41
 
5
42
 
@@ -124,6 +124,8 @@ cd /opt/emailengine
124
124
 
125
125
  Never expose EmailEngine directly to the internet. Use a reverse proxy with TLS.
126
126
 
127
+ The image starts EmailEngine with `EENGINE_API_PROXY=true`, so the client address is read from the `X-Forwarded-For` header. Set `EENGINE_API_PROXY_ADDRESSES` in `.env` to the address of your proxy (IPs or CIDRs, comma-separated; for a proxy on the Docker host this is usually the bridge gateway, e.g. `172.17.0.1`, or the proxy container's address). Without it the header is trusted from any peer, EmailEngine logs a warning on every start, and the admin IP allowlist and per-token address restrictions cannot be relied on.
128
+
127
129
  #### Option A: Nginx
128
130
 
129
131
  ```nginx
@@ -135,10 +137,10 @@ server {
135
137
  ssl_certificate_key /path/to/privkey.pem;
136
138
  ssl_protocols TLSv1.2 TLSv1.3;
137
139
 
138
- # Security headers
139
- add_header Strict-Transport-Security "max-age=31536000" always;
140
- add_header X-Frame-Options "SAMEORIGIN" always;
141
- add_header X-Content-Type-Options "nosniff" always;
140
+ # EmailEngine sends its own security headers (Content-Security-Policy, X-Frame-Options,
141
+ # X-Content-Type-Options, Referrer-Policy, Permissions-Policy), and Strict-Transport-Security
142
+ # once the service URL setting is https. Do not add them here as well: a second copy of a
143
+ # header is at best redundant and, for Content-Security-Policy, the two are both enforced.
142
144
 
143
145
  location / {
144
146
  proxy_pass http://127.0.0.1:3000;
@@ -175,12 +177,11 @@ server {
175
177
  ```caddyfile
176
178
  emailengine.example.com {
177
179
  reverse_proxy localhost:3000
178
- header Strict-Transport-Security "max-age=31536000"
179
- header X-Frame-Options "SAMEORIGIN"
180
- header X-Content-Type-Options "nosniff"
181
180
  }
182
181
  ```
183
182
 
183
+ EmailEngine sets the security headers itself (see the note in the Nginx example), so the Caddyfile needs no `header` lines.
184
+
184
185
  ### Step 3: Firewall Configuration
185
186
 
186
187
  ```bash
package/Dockerfile CHANGED
@@ -1,5 +1,17 @@
1
- # node:22.13.1-alpine
2
- FROM --platform=${TARGETPLATFORM} node@sha256:e2b39f7b64281324929257d0f8004fb6cb4bf0fdfb9aa8cedb235a766aec31da
1
+ # Pinned by tag AND digest: the digest is what actually gets pulled, so a rebuild of an old commit
2
+ # resolves the same Node layer, and the tag next to it keeps the line readable and lets Dependabot
3
+ # parse it (it does not follow an ARG-defined image). Both stages must stay on the same pin.
4
+ #
5
+ # The pin has to be moved deliberately - it sat on node:22.13.1-alpine for 19 months, which is how
6
+ # the image ended up shipping 21 unpatched Alpine CVEs. `apk upgrade` below covers the drift between
7
+ # pin bumps, and the docker_scan job in .github/workflows/test.yml fails the build once a fix for a
8
+ # HIGH/CRITICAL exists but is not picked up.
9
+
10
+ # Build stage. Everything that needs a package manager, a shell or a writable source tree happens
11
+ # here; the runtime stage below copies out only the finished tree, so npm and its dependencies never
12
+ # reach the published image. npm accounted for 38 of the 59 HIGH/CRITICAL findings in the old image
13
+ # (a vendored tar, pacote, sigstore, minimatch) and nothing at runtime ever invokes it.
14
+ FROM node:24-alpine@sha256:e67514e5d0f6c46656005e1b693b2ec9d52e80b641307de684d4a015ba7a4eaf AS builder
3
15
 
4
16
  ARG BUILDPLATFORM
5
17
  ARG TARGETPLATFORM
@@ -12,11 +24,6 @@ RUN printf "I'm building for TARGETPLATFORM=${TARGETPLATFORM}" \
12
24
  && printf "With uname -s : " && uname -s \
13
25
  && printf "and uname -m : " && uname -mm
14
26
 
15
- RUN apk add --no-cache dumb-init
16
-
17
- # Create a non-root user and group
18
- RUN addgroup -S emailenginegroup && adduser -S emailengineuser -G emailenginegroup
19
-
20
27
  WORKDIR /emailengine
21
28
 
22
29
  # Install dependencies before copying any source. npm ci is by far the slowest step in this
@@ -51,12 +58,29 @@ COPY server.js server.js
51
58
  RUN mkdir -p .git/refs/heads
52
59
  COPY .git/refs/heads/master .git/refs/heads/master
53
60
 
61
+ # version-info.json is generated here and the inputs are dropped again, so neither the git ref nor
62
+ # the script itself ends up in the runtime image.
54
63
  COPY update-info.sh update-info.sh
55
- RUN chmod +x ./update-info.sh
56
- RUN ./update-info.sh
64
+ RUN chmod +x ./update-info.sh \
65
+ && ./update-info.sh \
66
+ && rm -rf .git update-info.sh
67
+
68
+ # Runtime stage.
69
+ FROM node:24-alpine@sha256:e67514e5d0f6c46656005e1b693b2ec9d52e80b641307de684d4a015ba7a4eaf
70
+
71
+ # `apk upgrade` patches the Alpine packages that the base image itself lags on - at the time of
72
+ # writing node:24-alpine still carries an openssl below 3.5.8-r0. dumb-init reaps zombies as PID 1.
73
+ # npm is removed outright: it is a build-time tool, and leaving it in only adds scan surface.
74
+ RUN apk add --no-cache dumb-init \
75
+ && apk upgrade --no-cache \
76
+ && rm -rf /usr/local/lib/node_modules/npm /usr/local/bin/npm /usr/local/bin/npx
77
+
78
+ # Create a non-root user and group
79
+ RUN addgroup -S emailenginegroup && adduser -S emailengineuser -G emailenginegroup
80
+
81
+ WORKDIR /emailengine
57
82
 
58
- # Ensure permissions are set correctly for the non-root user
59
- RUN chown -R emailengineuser:emailenginegroup /emailengine
83
+ COPY --from=builder --chown=emailengineuser:emailenginegroup /emailengine /emailengine
60
84
 
61
85
  RUN node -e "console.log('node arch: ' + os.arch())"
62
86
  RUN node -e "console.log(process.versions)"
@@ -95,11 +95,38 @@ const GLOBAL_OPTIONS = [
95
95
  { name: '--log.level', description: 'Logging level', type: 'string', default: 'trace', group: 'General' },
96
96
  { name: '--log.raw', description: 'Log raw IMAP traffic', type: 'boolean', default: false, group: 'General' },
97
97
  { name: '--workers.webhooks', description: 'Number of webhook worker threads', type: 'number', default: 1, group: 'General' },
98
+ { name: '--workers.submit', description: 'Number of email submission worker threads', type: 'number', default: 1, group: 'General' },
99
+ { name: '--workers.export', description: 'Number of export worker threads', type: 'number', default: 1, group: 'General' },
100
+ {
101
+ name: '--workers.api',
102
+ description: 'Number of API/HTTP worker threads (values above 1 need SO_REUSEPORT, Linux only, otherwise 1 is used)',
103
+ type: 'number',
104
+ default: 1,
105
+ group: 'General'
106
+ },
98
107
  { name: '--api.host', description: 'API server bind address', type: 'string', default: '127.0.0.1', group: 'API server' },
99
108
  { name: '--api.port', description: 'API server port', type: 'number', default: 3000, group: 'API server' },
100
109
  { name: '--api.maxSize', description: 'Maximum attachment size', type: 'number/string', default: '5M', group: 'API server' },
110
+ { name: '--api.maxBodySize', description: 'Maximum API request body size', type: 'number/string', default: '50M', group: 'API server' },
111
+ {
112
+ name: '--api.maxPayloadTimeout',
113
+ description: 'Maximum time to wait for a request body to arrive',
114
+ type: 'number/string',
115
+ default: '10s',
116
+ group: 'API server'
117
+ },
118
+ {
119
+ name: '--api.proxy',
120
+ description: 'Trust X-Forwarded-For from the reverse proxy in front of the API (restrict the peers with EENGINE_API_PROXY_ADDRESSES)',
121
+ type: 'boolean',
122
+ default: false,
123
+ group: 'API server'
124
+ },
125
+ { name: '--api.tls.certPath', description: 'Path to the TLS certificate; setting it serves the API over HTTPS', type: 'string', group: 'API server' },
126
+ { name: '--api.tls.keyPath', description: 'Path to the TLS private key', type: 'string', group: 'API server' },
101
127
  { name: '--queues.notify', description: 'Concurrent webhook deliveries', type: 'number', default: 1, group: 'Background tasks' },
102
128
  { name: '--queues.submit', description: 'Concurrent email submissions', type: 'number', default: 1, group: 'Background tasks' },
129
+ { name: '--queues.export', description: 'Concurrent export operations', type: 'number', default: 1, group: 'Background tasks' },
103
130
  { name: '--smtp.enabled', description: 'Enable SMTP submission server', type: 'boolean', default: false, group: 'SMTP server' },
104
131
  { name: '--smtp.secret', description: 'Shared SMTP password for all accounts', type: 'string', group: 'SMTP server' },
105
132
  { name: '--smtp.host', description: 'SMTP server bind address', type: 'string', default: '127.0.0.1', group: 'SMTP server' },
@@ -220,11 +247,7 @@ function generateHelp() {
220
247
 
221
248
  lines.push('emailengine [command] [options]');
222
249
  lines.push('');
223
- lines.push(wrapText(
224
- 'EmailEngine is the self-hosted service that allows you to access any email account using an easy-to-use REST API.',
225
- width,
226
- 0
227
- ));
250
+ lines.push(wrapText('EmailEngine is the self-hosted service that allows you to access any email account using an easy-to-use REST API.', width, 0));
228
251
  lines.push('');
229
252
  lines.push('Commands:');
230
253
 
@@ -233,14 +256,7 @@ function generateHelp() {
233
256
  const cmdName = cmd ? `emailengine ${cmd}` : 'emailengine';
234
257
  lines.push(formatLine(cmdName, def.description, null, null, width, nameWidth));
235
258
  if (def.subcommands) {
236
- lines.push(formatLine(
237
- `emailengine ${cmd} [command]`,
238
- `${cmd.charAt(0).toUpperCase() + cmd.slice(1)} management`,
239
- null,
240
- null,
241
- width,
242
- nameWidth
243
- ));
259
+ lines.push(formatLine(`emailengine ${cmd} [command]`, `${cmd.charAt(0).toUpperCase() + cmd.slice(1)} management`, null, null, width, nameWidth));
244
260
  }
245
261
  }
246
262
 
@@ -4,32 +4,43 @@ imap = 4
4
4
  # Number of API/HTTP workers. Values >1 require SO_REUSEPORT (Linux); on other platforms it falls back to 1.
5
5
  api = 1
6
6
  webhooks = 1
7
- "imapProxy" = 1
7
+ submit = 1
8
+ export = 1
9
+ # The IMAP proxy runs as a single worker, started by the imapProxyServerEnabled setting
8
10
 
9
11
  [queues]
10
12
  # concurrency values
11
13
  submit = 1
12
14
  notify = 1
15
+ export = 1
13
16
 
14
17
  [service]
15
18
  #commandTimeout = "10s" # how much time to wait until IMAP command is deemed as failed
16
- #localAddresses = "ip1,ip2" # somma separated list of local IP addresses to use for tcp connections
17
19
  #secret = "secret_encryption_key" # key to encrypt passwords and Oauth tokens in DB
18
20
  #setupDelay = "0ms" # how much time to wait until assigning next IMAP connection to a worker
21
+ # Local IP addresses for outbound connections are an admin setting (localAddresses), not a config value
19
22
 
20
23
  [api]
21
24
  port = 3000
22
25
  host = "127.0.0.1" # by default API server is accessible from localhost only
23
26
  maxSize = "5M" # maximum size of an attachment when submitting or uploading messages
24
- #auth = "user:pass" # If set then uses Basic Auth
27
+ #maxBodySize = "50M" # maximum size of an API request body
28
+ #maxPayloadTimeout = "10s" # how long to wait for a request body to arrive
29
+ #proxy = false # trust X-Forwarded-For from a reverse proxy (restrict the peers with EENGINE_API_PROXY_ADDRESSES)
30
+ #cspMode = "enforce" # Content-Security-Policy delivery: "enforce", "report-only" (violations are only reported to the browser console) or "off"
31
+ # Serve the API over HTTPS by pointing at a certificate and key
32
+ #[api.tls]
33
+ #certPath = "/path/to/cert.pem"
34
+ #keyPath = "/path/to/key.pem"
25
35
 
26
36
  [smtp]
27
37
  enabled = false
28
38
  port = 2525
29
39
  host = "127.0.0.1"
30
- secret = "" # client password, if not set allows any password
40
+ secret = "" # shared client password; when unset, clients authenticate with an API token that has the "smtp" scope
31
41
  proxy = false # Set to true if using HAProxy with send-proxy option
32
42
  #maxMessageSize = "25M" # maximum message size accepted by SMTP server (default: 25MB)
43
+ #maxClients = 100 # concurrent SMTP server connections; excess connections are refused with a 421 (default: 100)
33
44
 
34
45
  [documentStore]
35
46
  # Deprecated Document Store (ElasticSearch) feature. Disabled by default; the worker and
@@ -13,11 +13,6 @@ cp node_modules/ace-builds/src-min/mode-html.js static/js/ace/
13
13
  cp node_modules/ace-builds/src-min/mode-json.js static/js/ace/
14
14
  cp node_modules/ace-builds/src-min/mode-javascript.js static/js/ace/
15
15
  cp node_modules/ace-builds/src-min/mode-markdown.js static/js/ace/
16
- cp node_modules/ace-builds/src-min/theme-xcode.js static/js/ace/
17
- cp node_modules/ace-builds/src-min/theme-kuroir.js static/js/ace/
18
- # dark-theme counterparts applied by uiAceEditor/uiAcePreview (static/js/ui.js)
19
- cp node_modules/ace-builds/src-min/theme-tomorrow_night.js static/js/ace/
20
- cp node_modules/ace-builds/src-min/theme-tomorrow_night_eighties.js static/js/ace/
21
16
  cp node_modules/ace-builds/src-min/worker-html.js static/js/ace/
22
17
  cp node_modules/ace-builds/src-min/worker-json.js static/js/ace/
23
18
  cp node_modules/ace-builds/src-min/worker-javascript.js static/js/ace/
@@ -25,8 +20,31 @@ cp node_modules/ace-builds/src-min/snippets/javascript.js static/js/ace/snippets
25
20
  cp node_modules/ace-builds/src-min/snippets/markdown.js static/js/ace/snippets
26
21
  cp node_modules/ace-builds/src-min/ext-searchbox.js static/js/ace/ext-searchbox.js
27
22
 
23
+ # ACE stylesheets, linked by views/partials/ace_assets.hbs. That partial also puts ACE in
24
+ # strict-CSP mode, so it injects no <style> elements of its own and the admin
25
+ # Content-Security-Policy can require a nonce on every stylesheet.
26
+ mkdir -p static/js/ace/css/theme
27
+ cp node_modules/ace-builds/css/ace.css static/js/ace/css/
28
+
29
+ # The light/dark pairs uiAceEditor and uiAcePreview switch between (static/js/ui.js). Each theme
30
+ # needs its module (for the cssClass and isDark ACE reads from it) and its stylesheet.
31
+ for theme in xcode kuroir tomorrow_night tomorrow_night_eighties; do
32
+ cp node_modules/ace-builds/src-min/theme-$theme.js static/js/ace/
33
+ cp node_modules/ace-builds/css/theme/$theme.css static/js/ace/css/theme/
34
+ done
35
+
36
+ # The images the sheets reference. Both bases land in css/ - ace.css uses ./, a theme uses ../ -
37
+ # so one pass over the copied sheets covers them.
38
+ for image in $(grep -oh 'url("[^"]*")' static/js/ace/css/ace.css static/js/ace/css/theme/*.css | sed 's/^url("//; s/")$//; s/^\.\.\///; s/^\.\///' | sort -u); do
39
+ cp node_modules/ace-builds/css/$image static/js/ace/css/
40
+ done
41
+
28
42
  cp node_modules/\@postalsys/ee-client/index.js static/js/ee-client.js
29
43
 
44
+ # SimpleWebAuthn browser bundle, kept at the same version as @simplewebauthn/server (the
45
+ # devDependency exists only to be vendored here; login-passkey.js and passkey-register.js load it)
46
+ cp node_modules/\@simplewebauthn/browser/dist/bundle/index.umd.min.js static/vendor/simplewebauthn/browser.min.js
47
+
30
48
  # FlyonUI browser bundle (vendored like ace above; committed and bundled by pkg)
31
49
  cp node_modules/flyonui/flyonui.js static/js/flyonui.js
32
50
 
@@ -1,5 +1,5 @@
1
1
  {
2
- "creationTime": "2026-08-31T14:46:39.000000",
2
+ "creationTime": "2026-09-04T14:45:59.000000",
3
3
  "prefixes": [
4
4
  {
5
5
  "ipv6Prefix": "2001:4860:4801:2008::/64"
@@ -163,6 +163,9 @@
163
163
  {
164
164
  "ipv6Prefix": "2001:4860:4801:2042::/64"
165
165
  },
166
+ {
167
+ "ipv6Prefix": "2001:4860:4801:2043::/64"
168
+ },
166
169
  {
167
170
  "ipv6Prefix": "2001:4860:4801:2044::/64"
168
171
  },
@@ -601,6 +604,9 @@
601
604
  {
602
605
  "ipv4Prefix": "66.249.92.96/27"
603
606
  },
607
+ {
608
+ "ipv4Prefix": "72.14.199.0/27"
609
+ },
604
610
  {
605
611
  "ipv4Prefix": "72.14.199.128/27"
606
612
  },
@@ -23,17 +23,26 @@ services:
23
23
  - emailengine-network
24
24
  environment:
25
25
  # Configuration via environment variables
26
- # For full list see https://github.com/postalsys/emailengine#config-mapping
26
+ # For the full list see https://learn.emailengine.app/docs/configuration
27
27
 
28
28
  # Settings to write to v1/settings on startup
29
29
  EENGINE_SETTINGS: ${EENGINE_SETTINGS:-}
30
30
 
31
- # Encryption secret - REQUIRED for production
32
- EENGINE_SECRET: ${EENGINE_SECRET:-default-dev-secret-change-in-production}
31
+ # Encryption secret for stored credentials - REQUIRED. Generate one with
32
+ # `openssl rand -hex 32` and put it in .env; compose refuses to start without it,
33
+ # since a default here would encrypt every account password with a public key
34
+ EENGINE_SECRET: '${EENGINE_SECRET:?EENGINE_SECRET must be set in .env - generate one with openssl rand -hex 32}'
33
35
 
34
36
  # Database connection URL
35
37
  EENGINE_REDIS: ${EENGINE_REDIS:-redis://redis:6379/2}
36
38
 
39
+ # The image trusts X-Forwarded-For (EENGINE_API_PROXY=true) so the client address
40
+ # comes from your reverse proxy. Name the proxy here (IPs or CIDRs, comma-separated,
41
+ # e.g. the Docker bridge gateway or the proxy container's address), otherwise any
42
+ # client that reaches the port directly can pick its own source address and the
43
+ # admin IP allowlist and per-token address restrictions cannot be relied on
44
+ EENGINE_API_PROXY_ADDRESSES: ${EENGINE_API_PROXY_ADDRESSES:-}
45
+
37
46
  # Additional settings
38
47
  EENGINE_LOG_LEVEL: ${EENGINE_LOG_LEVEL:-info}
39
48
  EENGINE_WORKERS: ${EENGINE_WORKERS:-4}
package/install.sh CHANGED
@@ -229,6 +229,8 @@ Environment=\"EENGINE_REDIS=redis://:${REDIS_PASSWORD}@127.0.0.1:6379/8\"
229
229
  Environment=\"EENGINE_PORT=3000\"
230
230
  Environment=\"EENGINE_SECRET=${EENGINE_SECRET}\"
231
231
  Environment=\"EENGINE_API_PROXY=true\"
232
+ # Caddy on this host is the only proxy allowed to set X-Forwarded-For
233
+ Environment=\"EENGINE_API_PROXY_ADDRESSES=127.0.0.1,::1\"
232
234
  Environment=\"EENGINE_WORKERS=8\"
233
235
  Environment=\"EENGINE_LOG_LEVEL=info\"
234
236
  # Triggers install script specific upgrade instructions
package/lib/account.js CHANGED
@@ -3141,6 +3141,8 @@ class Account {
3141
3141
  async invalidateAccessToken() {
3142
3142
  let accountData = await this.loadAccountData(this.account, false);
3143
3143
  if (accountData.oauth2) {
3144
+ // Rewinding the expiry is the whole encoding of "invalidated", and isAccessTokenInvalidated()
3145
+ // below is its decoder: change one and change the other
3144
3146
  accountData.oauth2.expires = new Date(Date.now() - 24 * 3600 * 1000).toISOString();
3145
3147
  await this.update({ account: accountData.account, oauth2: accountData.oauth2 });
3146
3148
  this.logger.info({ msg: 'Invalidated the OAuth2 access token', account: this.account, expires: accountData.oauth2.expires });
@@ -3369,4 +3371,27 @@ async function accountSummary(redis, account) {
3369
3371
  return { account, name: name || '', email: email || '', state: state || 'init' };
3370
3372
  }
3371
3373
 
3372
- module.exports = { Account, accountExists, accountsExist, accountSummary, authFailureDisabledAt, isAuthFailureDisabled, isOperatorDisabled };
3374
+ /**
3375
+ * Tells whether an account's access token was invalidated by Account#invalidateAccessToken().
3376
+ *
3377
+ * The invalidation rewinds `expires` by a day and leaves `generated` alone, so the token reads
3378
+ * as a validity window that ends before it starts. A live token can never have that shape (a
3379
+ * renewal writes both fields from the same clock), which makes the inversion the marker.
3380
+ *
3381
+ * @param {Object} oauth2 - The parsed oauth2 record of an account (dates as Date objects)
3382
+ * @returns {boolean}
3383
+ */
3384
+ function isAccessTokenInvalidated(oauth2) {
3385
+ return !!(oauth2 && oauth2.expires && oauth2.generated && oauth2.expires < oauth2.generated);
3386
+ }
3387
+
3388
+ module.exports = {
3389
+ Account,
3390
+ accountExists,
3391
+ accountsExist,
3392
+ accountSummary,
3393
+ authFailureDisabledAt,
3394
+ isAuthFailureDisabled,
3395
+ isOperatorDisabled,
3396
+ isAccessTokenInvalidated
3397
+ };
@@ -2,7 +2,7 @@
2
2
 
3
3
  const crypto = require('crypto');
4
4
  const { redis } = require('../db');
5
- const { Account, authFailureDisabledAt } = require('../account');
5
+ const { Account, accountExists, authFailureDisabledAt } = require('../account');
6
6
  const getSecret = require('../get-secret');
7
7
  const { oauth2Apps, SERVICE_ACCOUNT_PROVIDERS } = require('../oauth2-apps');
8
8
  const settings = require('../settings');
@@ -1581,7 +1581,18 @@ async function init(args) {
1581
1581
  path: '/v1/logs/{account}',
1582
1582
 
1583
1583
  async handler(request) {
1584
- return getLogs(redis, request.params.account);
1584
+ try {
1585
+ // Existence probe, so an unknown account is a 404 rather than an empty download.
1586
+ // The same error loadAccountData() throws for a missing record, without the
1587
+ // record load and decrypts that only the existence answer is wanted from
1588
+ if (!(await accountExists(redis, request.params.account))) {
1589
+ throw Boom.notFound('Account record was not found for requested ID');
1590
+ }
1591
+
1592
+ return await getLogs(redis, request.params.account);
1593
+ } catch (err) {
1594
+ handleError(request, err);
1595
+ }
1585
1596
  },
1586
1597
  options: {
1587
1598
  description: 'Return stored logs for an account',
@@ -1601,7 +1612,7 @@ async function init(args) {
1601
1612
  openapi: {
1602
1613
  'x-ee-behavior': [BEHAVIOR.ACCOUNT_LOG_SCOPE],
1603
1614
  produces: ['text/plain'],
1604
- responses: apiResponses('Returns the account log as a plain text stream.', 400, 401, 403, 429, 500)
1615
+ responses: apiResponses('Returns the account log as a plain text stream.', 400, 401, 403, 404, 429, 500)
1605
1616
  }
1606
1617
  },
1607
1618
 
@@ -4,6 +4,7 @@ const { createBullBoard } = require('@bull-board/api');
4
4
  const { BullMQAdapter } = require('@bull-board/api/bullMQAdapter');
5
5
  const { HapiAdapter } = require('@bull-board/hapi');
6
6
  const { notifyQueue, submitQueue, documentsQueue } = require('../db');
7
+ const { BULL_BOARD_BASE_PATH } = require('../consts');
7
8
 
8
9
  async function init(args) {
9
10
  const { server } = args;
@@ -51,9 +52,9 @@ async function init(args) {
51
52
  }
52
53
  });
53
54
 
54
- serverAdapter.setBasePath('/admin/bull-board');
55
+ serverAdapter.setBasePath(BULL_BOARD_BASE_PATH);
55
56
  await server.register(serverAdapter.registerPlugin(), {
56
- routes: { prefix: '/admin/bull-board' }
57
+ routes: { prefix: BULL_BOARD_BASE_PATH }
57
58
  });
58
59
  }
59
60
 
@@ -189,6 +189,7 @@ async function init(args) {
189
189
  path: Joi.array()
190
190
  .items(Joi.string().max(256))
191
191
  .single()
192
+ .required()
192
193
  .example(['Parent folder', 'Subfolder'])
193
194
  .description('Mailbox path as an array or a string. If account is namespaced then namespace prefix is added by default.')
194
195
  .label('CreateMailboxPathInput')
@@ -305,7 +306,9 @@ async function init(args) {
305
306
  try {
306
307
  return await accountObject.deleteMailbox(request.query.path);
307
308
  } catch (err) {
308
- handleError(request, err);
309
+ // A delete the IMAP server refuses surfaces the same way a refused create or
310
+ // rename does (code plus details), not through the generic handler's info shape
311
+ throwMailboxError(request, err);
309
312
  }
310
313
  },
311
314
 
@@ -39,6 +39,7 @@ const MCP_MESSAGE_TEXT_MAX_BYTES = 64 * 1024;
39
39
 
40
40
  const {
41
41
  accountIdSchema,
42
+ messageIdSchema,
42
43
  messageDetailsSchema,
43
44
  messageListSchema,
44
45
  messageEntrySchema,
@@ -135,7 +136,7 @@ async function init(args) {
135
136
 
136
137
  params: Joi.object({
137
138
  account: accountIdSchema.required(),
138
- message: Joi.string().base64({ paddingRequired: false, urlSafe: true }).max(256).example('AAAAAQAACnA').required().description('Message ID')
139
+ message: messageIdSchema.required()
139
140
  }).label('RawMessageRequest')
140
141
  }
141
142
  }
@@ -265,7 +266,7 @@ async function init(args) {
265
266
 
266
267
  params: Joi.object({
267
268
  account: accountIdSchema.required(),
268
- message: Joi.string().base64({ paddingRequired: false, urlSafe: true }).max(256).required().example('AAAAAQAACnA').description('Message ID')
269
+ message: messageIdSchema.required()
269
270
  })
270
271
  },
271
272
 
@@ -522,7 +523,7 @@ async function init(args) {
522
523
 
523
524
  params: Joi.object({
524
525
  account: accountIdSchema.required(),
525
- message: Joi.string().max(256).required().example('AAAAAQAACnA').description('Message ID')
526
+ message: messageIdSchema.required()
526
527
  }),
527
528
 
528
529
  payload: messageUpdateSchema
@@ -692,7 +693,7 @@ async function init(args) {
692
693
 
693
694
  params: Joi.object({
694
695
  account: accountIdSchema.required(),
695
- message: Joi.string().max(256).required().example('AAAAAQAACnA').description('Message ID')
696
+ message: messageIdSchema.required()
696
697
  }),
697
698
 
698
699
  payload: Joi.object({
@@ -860,7 +861,7 @@ async function init(args) {
860
861
 
861
862
  params: Joi.object({
862
863
  account: accountIdSchema.required(),
863
- message: Joi.string().max(256).required().example('AAAAAQAACnA').description('Message ID')
864
+ message: messageIdSchema.required()
864
865
  }).label('MessageDelete')
865
866
  },
866
867
  response: {