emailengine-app 2.73.0 → 2.74.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/.github/docker-smoke-test.sh +45 -0
- package/.github/workflows/deploy.yml +22 -0
- package/.github/workflows/e2e.yml +1 -2
- package/.github/workflows/release.yaml +19 -0
- package/.github/workflows/test.yml +31 -0
- package/CHANGELOG.md +52 -0
- package/Dockerfile +14 -5
- package/README.md +55 -25
- package/config/e2e.toml +2 -2
- package/data/google-crawlers.json +1 -1
- package/lib/account.js +14 -6
- package/lib/api-routes/account-routes.js +4 -1
- package/lib/api-routes/token-routes.js +13 -0
- package/lib/consts.js +15 -25
- package/lib/delivery-error.js +34 -11
- package/lib/email-client/gmail-client.js +1 -1
- package/lib/email-client/imap/mailbox.js +96 -1
- package/lib/email-client/imap-client.js +101 -28
- package/lib/email-client/outlook-client.js +1 -1
- package/lib/es.js +0 -27
- package/lib/license-beacon.js +1 -5
- package/lib/schemas.js +12 -0
- package/lib/settings.js +13 -0
- package/lib/tokens.js +15 -0
- package/lib/ui-routes/account-routes.js +65 -5
- package/lib/ui-routes/admin-entities-routes.js +13 -0
- package/lib/worker-rpc-error.js +54 -0
- package/package.json +6 -6
- package/sbom.json +1 -1
- package/server.js +3 -19
- package/setup-production.sh +7 -2
- package/static/licenses.html +12 -12
- package/translations/messages.pot +36 -36
- package/views/accounts/edit.hbs +6 -0
- package/workers/api.js +5 -14
- package/workers/imap.js +3 -16
- package/workers/submit.js +3 -18
- package/.env.development +0 -49
- package/.env.example +0 -82
- package/.env.production +0 -87
- package/.eslintignore +0 -1
- package/Dockerfile-legacy +0 -18
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
#
|
|
3
|
+
# Smoke test the EmailEngine CLI inside a built image.
|
|
4
|
+
#
|
|
5
|
+
# The Dockerfile copies an explicit allowlist of root-level files rather than `COPY . .`, so a CLI
|
|
6
|
+
# subcommand that dispatches to one (e.g. `scan` -> ../scan.js, `encrypt` -> ../encrypt.js) can be
|
|
7
|
+
# missing from the image while the build and the server both stay green - CMD only runs server.js.
|
|
8
|
+
# Both `scan` and `encrypt` shipped broken that way. Exercising the commands catches it regardless of
|
|
9
|
+
# how the module is referenced, which a source-level check cannot.
|
|
10
|
+
#
|
|
11
|
+
# Runs against a locally-loaded image (see the workflows) BEFORE the multi-arch push, so a broken
|
|
12
|
+
# image is never published - the previous version smoke tested the already-pushed image and could
|
|
13
|
+
# only detect the regression, not prevent shipping it.
|
|
14
|
+
#
|
|
15
|
+
# Usage: docker-smoke-test.sh <image-ref>
|
|
16
|
+
set -euo pipefail
|
|
17
|
+
|
|
18
|
+
image="${1:?usage: docker-smoke-test.sh <image-ref>}"
|
|
19
|
+
status=0
|
|
20
|
+
|
|
21
|
+
# Only the subcommands that dispatch to a root-level module can exercise the allowlist; everything
|
|
22
|
+
# else resolves out of lib/ or node_modules. This list is a runtime spot-check, not the completeness
|
|
23
|
+
# authority - test/dockerfile-cli-modules-test.js derives the full set of root-level requires from
|
|
24
|
+
# bin/emailengine.js and fails if any is not COPYed. Add new root-dispatching subcommands here too.
|
|
25
|
+
for cmd in scan encrypt; do
|
|
26
|
+
# These subcommands need Redis or arguments and are expected to exit non-zero; we only assert the
|
|
27
|
+
# module resolved. Capture the exit code explicitly (no `|| true`, which would mask a container
|
|
28
|
+
# that never started) so a docker/exec failure - exit >=125 - is treated as a failure, not a pass.
|
|
29
|
+
out=$(docker run --rm --entrypoint node "$image" bin/emailengine.js "$cmd" 2>&1) && rc=0 || rc=$?
|
|
30
|
+
|
|
31
|
+
if [ "$rc" -ge 125 ]; then
|
|
32
|
+
echo "::error::container failed to start for 'emailengine $cmd' (exit $rc)"
|
|
33
|
+
printf '%s\n' "$out"
|
|
34
|
+
status=1
|
|
35
|
+
continue
|
|
36
|
+
fi
|
|
37
|
+
|
|
38
|
+
if grep -q "Cannot find module" <<<"$out"; then
|
|
39
|
+
echo "::error::emailengine $cmd cannot resolve its module inside the image"
|
|
40
|
+
printf '%s\n' "$out"
|
|
41
|
+
status=1
|
|
42
|
+
fi
|
|
43
|
+
done
|
|
44
|
+
|
|
45
|
+
exit $status
|
|
@@ -110,7 +110,27 @@ jobs:
|
|
|
110
110
|
tags: |
|
|
111
111
|
type=raw,value=edge,enable=true
|
|
112
112
|
|
|
113
|
+
# Build the amd64 image locally (no push) and smoke test the CLI BEFORE publishing, so a
|
|
114
|
+
# broken image is never pushed - the previous version smoke tested the already-pushed
|
|
115
|
+
# image and could only detect the regression, not prevent shipping it. This build replays
|
|
116
|
+
# from the same gha cache the multi-arch push below reuses, so it is cheap.
|
|
117
|
+
- name: Build for smoke test (amd64, local)
|
|
118
|
+
uses: docker/build-push-action@v7
|
|
119
|
+
with:
|
|
120
|
+
context: .
|
|
121
|
+
platforms: linux/amd64
|
|
122
|
+
load: true
|
|
123
|
+
tags: emailengine:smoke-test
|
|
124
|
+
# Without a cache backend BuildKit starts cold on every run: setup-buildx-action
|
|
125
|
+
# creates a fresh builder on an ephemeral runner, so the emulated arm64 `npm ci`
|
|
126
|
+
# re-runs in full regardless of how the Dockerfile layers are ordered.
|
|
127
|
+
cache-from: type=gha
|
|
128
|
+
|
|
129
|
+
- name: Smoke test the CLI inside the image
|
|
130
|
+
run: bash .github/docker-smoke-test.sh emailengine:smoke-test
|
|
131
|
+
|
|
113
132
|
- name: Build and push
|
|
133
|
+
id: build
|
|
114
134
|
uses: docker/build-push-action@v7
|
|
115
135
|
with:
|
|
116
136
|
context: .
|
|
@@ -118,3 +138,5 @@ jobs:
|
|
|
118
138
|
push: true
|
|
119
139
|
tags: ${{ steps.meta.outputs.tags }}
|
|
120
140
|
labels: ${{ steps.meta.outputs.labels }}
|
|
141
|
+
cache-from: type=gha
|
|
142
|
+
cache-to: type=gha,mode=max
|
|
@@ -3,8 +3,7 @@ name: E2E Tests
|
|
|
3
3
|
# Browser-driven happy-path end-to-end suite (test/e2e), kept separate from the unit and
|
|
4
4
|
# integration tiers so it is easy to re-run on its own and has its own requirements: it drives a
|
|
5
5
|
# real browser (Playwright/Chromium) and reaches external services (Ethereal for the test mailbox,
|
|
6
|
-
# postalsys.com for the 14-day trial).
|
|
7
|
-
# (https://e2e.emailengine.app/) - see the postalsys-web trial allowlist.
|
|
6
|
+
# postalsys.com for the 14-day trial).
|
|
8
7
|
|
|
9
8
|
on:
|
|
10
9
|
workflow_dispatch:
|
|
@@ -96,12 +96,31 @@ jobs:
|
|
|
96
96
|
username: ${{ github.repository_owner }}
|
|
97
97
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
98
98
|
|
|
99
|
+
# Build the amd64 image locally (no push) and smoke test the CLI BEFORE publishing, so a
|
|
100
|
+
# broken image is never pushed to the tags users pull - the previous version smoke tested
|
|
101
|
+
# the already-pushed image and could only detect the regression, not prevent shipping it.
|
|
102
|
+
# This build replays from the same gha cache the multi-arch push below reuses.
|
|
103
|
+
- name: Build for smoke test (amd64, local)
|
|
104
|
+
uses: docker/build-push-action@v7
|
|
105
|
+
with:
|
|
106
|
+
context: .
|
|
107
|
+
platforms: linux/amd64
|
|
108
|
+
load: true
|
|
109
|
+
tags: emailengine:smoke-test
|
|
110
|
+
cache-from: type=gha
|
|
111
|
+
|
|
112
|
+
- name: Smoke test the CLI inside the image
|
|
113
|
+
run: bash .github/docker-smoke-test.sh emailengine:smoke-test
|
|
114
|
+
|
|
99
115
|
- name: Build and push
|
|
116
|
+
id: build
|
|
100
117
|
uses: docker/build-push-action@v7
|
|
101
118
|
with:
|
|
102
119
|
context: .
|
|
103
120
|
platforms: ${{ steps.buildx.outputs.platforms }}
|
|
104
121
|
push: true
|
|
122
|
+
cache-from: type=gha
|
|
123
|
+
cache-to: type=gha,mode=max
|
|
105
124
|
tags: |
|
|
106
125
|
${{ github.repository }}:latest
|
|
107
126
|
${{ github.repository }}:v${{needs.release_please.outputs.major}}.${{needs.release_please.outputs.minor}}.${{needs.release_please.outputs.patch}}
|
|
@@ -100,6 +100,37 @@ jobs:
|
|
|
100
100
|
GMAIL_API_ACCOUNT_EMAIL_1: ${{ secrets.TEST_GMAIL_API_ACCOUNT_EMAIL_1 }}
|
|
101
101
|
GMAIL_API_ACCOUNT_REFRESH_1: ${{ secrets.TEST_GMAIL_API_ACCOUNT_REFRESH_1 }}
|
|
102
102
|
|
|
103
|
+
dovecot:
|
|
104
|
+
# Live IMAP tier against a real IMAP4rev2 server (Dovecot 2.4 in Docker);
|
|
105
|
+
# fully hermetic - needs no external mail accounts. See test/dovecot/README.md
|
|
106
|
+
name: Live Dovecot Tests (IMAP4rev2)
|
|
107
|
+
if: ${{ !startsWith(github.ref_name, 'release-please--') && !startsWith(github.head_ref, 'release-please--') }}
|
|
108
|
+
timeout-minutes: 15
|
|
109
|
+
runs-on: ubuntu-24.04
|
|
110
|
+
services:
|
|
111
|
+
redis:
|
|
112
|
+
image: redis
|
|
113
|
+
options: >-
|
|
114
|
+
--health-cmd "redis-cli ping"
|
|
115
|
+
--health-interval 10s
|
|
116
|
+
--health-timeout 5s
|
|
117
|
+
--health-retries 5
|
|
118
|
+
ports:
|
|
119
|
+
- 6379:6379
|
|
120
|
+
steps:
|
|
121
|
+
- uses: actions/checkout@v6
|
|
122
|
+
- name: Use Node.js 24
|
|
123
|
+
uses: actions/setup-node@v6
|
|
124
|
+
with:
|
|
125
|
+
node-version: 24
|
|
126
|
+
cache: npm
|
|
127
|
+
- run: npm install
|
|
128
|
+
- name: Run live Dovecot tests
|
|
129
|
+
run: |
|
|
130
|
+
npm run test:dovecot
|
|
131
|
+
env:
|
|
132
|
+
EENGINE_DOVECOT_PLATFORM: linux/amd64
|
|
133
|
+
|
|
103
134
|
integration:
|
|
104
135
|
name: Integration Tests
|
|
105
136
|
if: ${{ !startsWith(github.ref_name, 'release-please--') && !startsWith(github.head_ref, 'release-please--') }}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,57 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.74.0](https://github.com/postalsys/emailengine/compare/v2.73.1...v2.74.0) (2026-07-23)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **imap:** add a per-account IMAP4rev2 opt-out and account-level TLS certificate override ([59764fd](https://github.com/postalsys/emailengine/commit/59764fd16f5c895b2c3e714fc769482830a19a36))
|
|
9
|
+
* **ui:** add the account-level invalid-certificate override to the SMTP settings as well ([7d1b9e4](https://github.com/postalsys/emailengine/commit/7d1b9e44e91e9a251743e8b61413b4ef91a177b3))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* **accounts:** back out the OAuth2 auth-failure park ([bc431bd](https://github.com/postalsys/emailengine/commit/bc431bd3ede97d06f58788c66b7dfa8958380c49))
|
|
15
|
+
* **accounts:** make the auth-failure auto-disable work for OAuth2 accounts ([77f78b4](https://github.com/postalsys/emailengine/commit/77f78b4bd852c1662fee9657d84625ccdc58f143))
|
|
16
|
+
* **api:** require an admin session for the Bull Board queue browser ([392723e](https://github.com/postalsys/emailengine/commit/392723e746a83dc8fc7a96fd4c719114667f8b56))
|
|
17
|
+
* **api:** revert the Bull Board admin-session requirement ([14590b8](https://github.com/postalsys/emailengine/commit/14590b86e1557f3b6284401fbd4e1c06a9a72d01))
|
|
18
|
+
* **ci:** give the Docker builds a cache backend and smoke test by digest ([4554d90](https://github.com/postalsys/emailengine/commit/4554d90b5bf38f649b8c27c65a9c26cf39951e0d))
|
|
19
|
+
* **ci:** smoke-test the image before publishing and harden the allowlist test ([c285fcb](https://github.com/postalsys/emailengine/commit/c285fcbbd258846537447cd730342423e6b2eaf7))
|
|
20
|
+
* **deps:** update dependencies ([3370f0a](https://github.com/postalsys/emailengine/commit/3370f0aa3afeb3b07bb5627602a314ec6aaf89fa))
|
|
21
|
+
* **deps:** update dependencies ([e1256b2](https://github.com/postalsys/emailengine/commit/e1256b296f83be3fe161f38af5087d231c8fa3bf))
|
|
22
|
+
* **deps:** update dependencies (imapflow 1.5.0) ([8cc45ac](https://github.com/postalsys/emailengine/commit/8cc45acacb8572d5cf9a187a34d6d284b57d4b99))
|
|
23
|
+
* **docker:** ship the root-level CLI modules in the image ([a63cb4e](https://github.com/postalsys/emailengine/commit/a63cb4e17b3fac9b8e003914b3472f1da20dd6ec))
|
|
24
|
+
* **gitignore:** cover every local env file, not just the exact name ([16124d5](https://github.com/postalsys/emailengine/commit/16124d5e83cb9ead3a0c8520db7fcb4e5eefedaa))
|
|
25
|
+
* **imap:** park phantom folders and throttle short-lived-connection reconnects ([da97da3](https://github.com/postalsys/emailengine/commit/da97da31eddcb327672daf28938efec11b5e55f7))
|
|
26
|
+
* **imap:** store the connection error response as text, not as a parsed object ([3cf8d2e](https://github.com/postalsys/emailengine/commit/3cf8d2e016ce0e8ce623468689ef6f21a90cd6f1))
|
|
27
|
+
* **oauth:** drop the transient token-refresh carve-out, keep the stale-token fix ([63c2d8c](https://github.com/postalsys/emailengine/commit/63c2d8c261a71158ea5670ddc7e080c690240265))
|
|
28
|
+
* **oauth:** make the transient token-failure and delivery-retry fixes actually fire ([5049fea](https://github.com/postalsys/emailengine/commit/5049fea5f1724d4e7ae2fa6f2b58a642af4f7f6b))
|
|
29
|
+
* **oauth:** report transient token failures instead of stalling on them ([10b3480](https://github.com/postalsys/emailengine/commit/10b348082016f047eda641602bfe370d1195e222))
|
|
30
|
+
* **oauth:** stop reporting a rate-limited token endpoint as bad credentials ([de27fca](https://github.com/postalsys/emailengine/commit/de27fca5ed0c42cabb95553a00323dc82fc422bc))
|
|
31
|
+
* **setup:** create production secret files owner-only ([52f0527](https://github.com/postalsys/emailengine/commit/52f052741558e9b3a5478fe2f0ecc5fb0a1679f9))
|
|
32
|
+
* **submit:** retry transient 4xx SMTP rejections and gate token minting on the request principal ([1688c86](https://github.com/postalsys/emailengine/commit/1688c86522d9e79715569e6735353c333d7e527c))
|
|
33
|
+
* **submit:** stop discarding queued mail on non-SMTP 5xx errors ([f80f475](https://github.com/postalsys/emailengine/commit/f80f4754c76e230db529031c0549caf26468d891))
|
|
34
|
+
* **test:** provision scope-test tokens as a trusted local caller ([20ca781](https://github.com/postalsys/emailengine/commit/20ca7817f3679797bb07e17d00e9b4cd5d6d7c4b))
|
|
35
|
+
* **tokens:** refuse to mint an access token before an admin password is set ([ff3dd47](https://github.com/postalsys/emailengine/commit/ff3dd47b06ebac2d7f861fe66e26549db193a9f8))
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
### Performance Improvements
|
|
39
|
+
|
|
40
|
+
* **docker:** cache the dependency install and smoke test the CLI in the image ([e275733](https://github.com/postalsys/emailengine/commit/e275733dacc85ba72ea3465013242785c2d7adcf))
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
### Reverts
|
|
44
|
+
|
|
45
|
+
* back out the OAuth2 token-failure rework, keep the delivery and token fixes ([496ac3d](https://github.com/postalsys/emailengine/commit/496ac3d9c8737fecaf5ccf21bf98d1bd51e7af5c))
|
|
46
|
+
|
|
47
|
+
## [2.73.1](https://github.com/postalsys/emailengine/compare/v2.73.0...v2.73.1) (2026-07-21)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
### Bug Fixes
|
|
51
|
+
|
|
52
|
+
* **imap:** stop the OAuth token renewal reconnect loop that pinned the CPU ([eff5727](https://github.com/postalsys/emailengine/commit/eff5727f4a328326609856861465f524e381689c))
|
|
53
|
+
* restore the scan CLI command and stop packing secrets into the tarball ([edddb4e](https://github.com/postalsys/emailengine/commit/edddb4e70e96a7267880e295f0d9448b16ed214e))
|
|
54
|
+
|
|
3
55
|
## [2.73.0](https://github.com/postalsys/emailengine/compare/v2.72.4...v2.73.0) (2026-07-20)
|
|
4
56
|
|
|
5
57
|
|
package/Dockerfile
CHANGED
|
@@ -19,6 +19,15 @@ RUN addgroup -S emailenginegroup && adduser -S emailengineuser -G emailenginegro
|
|
|
19
19
|
|
|
20
20
|
WORKDIR /emailengine
|
|
21
21
|
|
|
22
|
+
# Install dependencies before copying any source. npm ci is by far the slowest step in this
|
|
23
|
+
# build - it runs under QEMU emulation for the non-native architecture - and Docker invalidates
|
|
24
|
+
# every layer below a changed one. With the sources copied first, an edit to any file busted
|
|
25
|
+
# this layer and re-ran the whole install; keeping it above them means it is only re-run when
|
|
26
|
+
# the lockfile actually changes.
|
|
27
|
+
COPY package.json package.json
|
|
28
|
+
COPY package-lock.json package-lock.json
|
|
29
|
+
RUN npm ci --omit=dev
|
|
30
|
+
|
|
22
31
|
# Copy app folders
|
|
23
32
|
COPY bin bin
|
|
24
33
|
COPY config config
|
|
@@ -30,19 +39,19 @@ COPY views views
|
|
|
30
39
|
COPY workers workers
|
|
31
40
|
|
|
32
41
|
# Copy required root level files
|
|
42
|
+
# NB: bin/emailengine.js requires ../encrypt and ../scan for the `encrypt` and `scan`
|
|
43
|
+
# subcommands. This COPY list is an allowlist, so any root-level module the CLI dispatches
|
|
44
|
+
# to must be named here or the command fails with MODULE_NOT_FOUND inside the container.
|
|
33
45
|
COPY LICENSE_EMAILENGINE.txt LICENSE_EMAILENGINE.txt
|
|
34
|
-
COPY
|
|
35
|
-
COPY package-lock.json package-lock.json
|
|
46
|
+
COPY encrypt.js encrypt.js
|
|
36
47
|
COPY sbom.json sbom.json
|
|
48
|
+
COPY scan.js scan.js
|
|
37
49
|
COPY server.js server.js
|
|
38
50
|
|
|
39
51
|
RUN mkdir -p .git/refs/heads
|
|
40
52
|
COPY .git/refs/heads/master .git/refs/heads/master
|
|
41
53
|
|
|
42
54
|
COPY update-info.sh update-info.sh
|
|
43
|
-
|
|
44
|
-
RUN npm ci --omit=dev
|
|
45
|
-
RUN npm run prepare-docker
|
|
46
55
|
RUN chmod +x ./update-info.sh
|
|
47
56
|
RUN ./update-info.sh
|
|
48
57
|
|
package/README.md
CHANGED
|
@@ -16,27 +16,37 @@ A headless email client application that provides access to IMAP, SMTP, Gmail AP
|
|
|
16
16
|
- [Monitor INBOX and Junk folders](https://learn.emailengine.app/docs/advanced/inbox-placement-testing) of a test email account to track where sent emails land.
|
|
17
17
|
- Ideal for lightweight webmail and mobile email apps that prefer to avoid direct IMAP and MIME processing.
|
|
18
18
|
|
|
19
|
+
## Features
|
|
20
|
+
|
|
21
|
+
- **One REST API for every provider.** IMAP/SMTP, the Gmail API, and Microsoft Graph are all exposed through the same endpoints, so your integration does not change when a user switches provider.
|
|
22
|
+
- **Real-time webhooks.** Get notified about new, deleted, and updated messages, sent mail, delivery errors, bounces, and account state changes. Optional [custom routes](https://learn.emailengine.app/docs/webhooks/webhook-routing) filter and reshape payloads per destination.
|
|
23
|
+
- **Sending.** Queued delivery with retries, stored [templates](https://learn.emailengine.app/docs/sending/templates), sending gateways, open and click tracking, unsubscribe handling, a blocklist, and bounce classification.
|
|
24
|
+
- **Account onboarding.** A [hosted authentication form](https://learn.emailengine.app/docs/accounts/hosted-authentication) handles OAuth2 (Google, Microsoft) and IMAP credentials so you never touch the user's password.
|
|
25
|
+
- **Bulk export.** Export an account's mail to compressed NDJSON, optionally encrypted.
|
|
26
|
+
- **Protocol servers for legacy apps.** A built-in SMTP submission server (MSA) and an IMAP proxy let existing clients reach OAuth2-only mailboxes without implementing OAuth2 themselves.
|
|
27
|
+
- **Admin interface.** Server-rendered dashboard with light and dark themes, an embedded API reference, queue inspection, and logs.
|
|
28
|
+
- **Admin authentication.** Password, passkeys (WebAuthn), TOTP two-factor, and SSO through Okta or any OpenID Connect provider (Keycloak, Authentik, Entra ID, Google).
|
|
29
|
+
- **Operations.** Prometheus metrics, structured logging, and a 7-language admin UI.
|
|
30
|
+
|
|
19
31
|
## Quickstart
|
|
20
32
|
|
|
21
33
|
- [Setup Instructions](https://learn.emailengine.app/docs/getting-started/quick-start)
|
|
22
34
|
|
|
23
35
|
## Screenshots
|
|
24
36
|
|
|
25
|
-

|
|
38
|
+

|
|
39
|
+

|
|
36
40
|
|
|
37
41
|
## Requirements
|
|
38
42
|
|
|
39
|
-
- **
|
|
43
|
+
- **Node.js** - version 20 or newer (only when running from source; the prebuilt binaries and the Docker image bundle their own runtime)
|
|
44
|
+
- **Redis** - any version
|
|
45
|
+
|
|
46
|
+
> [!IMPORTANT]
|
|
47
|
+
> EmailEngine uses Redis as its primary database, not as a cache. Set `maxmemory-policy` to `noeviction` and give Redis enough memory for your workload - with any other policy Redis can drop sync state, which makes already-synced messages look new and generates duplicate webhooks.
|
|
48
|
+
>
|
|
49
|
+
> Redis Cluster and Amazon ElastiCache are **not** supported. Use a standard Redis primary instance. EmailEngine warns about all of the above on the dashboard when it detects them.
|
|
40
50
|
|
|
41
51
|
> [!NOTE]
|
|
42
52
|
> While Redis does not officially support Windows, alternatives like [Memurai](https://www.memurai.com/) are available.
|
|
@@ -48,7 +58,7 @@ $ emailengine license
|
|
|
48
58
|
|
|
49
59
|
- [Documentation](https://learn.emailengine.app/)
|
|
50
60
|
- [API Reference](https://learn.emailengine.app/docs/api/emailengine-api)
|
|
51
|
-
- OpenAPI specification for Postman: [swagger.json](https://emailengine.dev/swagger.json)
|
|
61
|
+
- OpenAPI specification for Postman and code generators: every instance serves its own at `/swagger.json`, or use the hosted copy at [emailengine.dev/swagger.json](https://emailengine.dev/swagger.json)
|
|
52
62
|
|
|
53
63
|
## Configuring EmailEngine
|
|
54
64
|
|
|
@@ -64,19 +74,19 @@ By default, EmailEngine only allows connections from localhost. To enable extern
|
|
|
64
74
|
|
|
65
75
|
You can use the included install script to set up:
|
|
66
76
|
|
|
77
|
+
- Redis as the data store
|
|
67
78
|
- EmailEngine as a SystemD service
|
|
68
79
|
- Caddy as a reverse proxy and HTTPS certificate handler
|
|
69
80
|
|
|
81
|
+
The script must run as root, and takes the domain name for EmailEngine as its first argument:
|
|
82
|
+
|
|
70
83
|
```bash
|
|
71
84
|
$ wget https://raw.githubusercontent.com/postalsys/emailengine/master/install.sh
|
|
72
85
|
$ chmod +x install.sh
|
|
73
|
-
$ ./install.sh example.com
|
|
86
|
+
$ sudo ./install.sh example.com
|
|
74
87
|
```
|
|
75
88
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
> [!NOTE]
|
|
79
|
-
> Tested on Ubuntu 20.04 and Debian 11. Other versions may not be supported.
|
|
89
|
+
Pass a version as the optional second argument to install a specific release instead of the latest one. Re-running the script on an existing installation upgrades it in place, and it also installs `/opt/upgrade-emailengine.sh` for later upgrades.
|
|
80
90
|
|
|
81
91
|
### SystemD
|
|
82
92
|
|
|
@@ -100,7 +110,25 @@ To execute EmailEngine-CLI commands within a Docker container:
|
|
|
100
110
|
$ node bin/emailengine.js <command>
|
|
101
111
|
```
|
|
102
112
|
|
|
103
|
-
For full Docker usage documentation, visit [here](https://learn.emailengine.app/docs/installation/docker).
|
|
113
|
+
For full Docker usage documentation, visit [here](https://learn.emailengine.app/docs/installation/docker). This repository also ships a `docker-compose.yml` and a longer [Docker deployment guide](./DOCKER_DEPLOYMENT.md).
|
|
114
|
+
|
|
115
|
+
## Command Line Interface
|
|
116
|
+
|
|
117
|
+
Run `emailengine help` for the full list, or `emailengine help <command>` for a single one.
|
|
118
|
+
|
|
119
|
+
| Command | Description |
|
|
120
|
+
| -------------------------- | ---------------------------------------------------- |
|
|
121
|
+
| `emailengine` | Start the EmailEngine server |
|
|
122
|
+
| `emailengine version` | Show the version number |
|
|
123
|
+
| `emailengine license` | Show the EmailEngine version and license terms |
|
|
124
|
+
| `emailengine password` | Set or reset the admin password |
|
|
125
|
+
| `emailengine tokens` | Issue, export, and import API access tokens |
|
|
126
|
+
| `emailengine encrypt` | Manage field-level encryption for stored credentials |
|
|
127
|
+
| `emailengine export` | Export account data, including credentials |
|
|
128
|
+
| `emailengine scan` | Scan the Redis keyspace and output a CSV report |
|
|
129
|
+
| `emailengine check-bounce` | Analyze a bounce email and classify it |
|
|
130
|
+
|
|
131
|
+
The license terms of the bundled third-party modules are not part of `emailengine license` - a running instance serves them at [http://127.0.0.1:3000/licenses.html](http://127.0.0.1:3000/licenses.html).
|
|
104
132
|
|
|
105
133
|
## Resolving Issues with Redis
|
|
106
134
|
|
|
@@ -108,7 +136,7 @@ EmailEngine relies on Redis as its data store. Redis stores everything in RAM, s
|
|
|
108
136
|
|
|
109
137
|
To diagnose problems:
|
|
110
138
|
|
|
111
|
-
1. **Check
|
|
139
|
+
1. **Check the job queues:** Use the built-in Bull Board UI to monitor queue states at [http://127.0.0.1:3000/admin/bull-board](http://127.0.0.1:3000/admin/bull-board) (requires an admin session).
|
|
112
140
|
2. **Scan Keyspace:** Run the following to group Redis keys by type and generate a report:
|
|
113
141
|
|
|
114
142
|
```bash
|
|
@@ -117,17 +145,19 @@ To diagnose problems:
|
|
|
117
145
|
|
|
118
146
|
## Monitoring
|
|
119
147
|
|
|
120
|
-
EmailEngine provides Prometheus metrics
|
|
148
|
+
EmailEngine provides Prometheus metrics at the `/metrics` URL path. The endpoint requires an access token with the `metrics` or `*` scope:
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
$ curl -H "Authorization: Bearer $EE_TOKEN" http://127.0.0.1:3000/metrics
|
|
152
|
+
```
|
|
121
153
|
|
|
122
154
|
## Log Analysis
|
|
123
155
|
|
|
124
156
|
For information on logging options, read the documentation [here](https://learn.emailengine.app/docs/advanced/logging).
|
|
125
157
|
|
|
126
|
-
To trace IMAP traffic for a
|
|
158
|
+
To trace the IMAP traffic of a single account, open that account in the admin interface and turn on logging for it. EmailEngine then keeps a rolling log for the account, which you can read on the same page or download as a text file.
|
|
127
159
|
|
|
128
|
-
|
|
129
|
-
$ npm run raw -- --filter.account=account1
|
|
130
|
-
```
|
|
160
|
+
To log raw IMAP traffic for every account instead, start EmailEngine with `--log.raw=true` (or `EENGINE_LOG_RAW=true`). This is verbose and includes message content, so keep it off in production.
|
|
131
161
|
|
|
132
162
|
## Security and Data Compliance
|
|
133
163
|
|
package/config/e2e.toml
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
# preparedLicense here on purpose - the suite enables auth and activates the trial through the UI.
|
|
8
8
|
|
|
9
9
|
# JSON formatted settings, seeded on startup.
|
|
10
|
-
# serviceUrl
|
|
11
|
-
#
|
|
10
|
+
# serviceUrl identifies this throwaway e2e instance to the trial endpoint. It is only used as the
|
|
11
|
+
# trial request's `url`; the browser and API talk to 127.0.0.1:7099.
|
|
12
12
|
settings = '''
|
|
13
13
|
{
|
|
14
14
|
"serviceUrl": "https://e2e.emailengine.app/",
|
package/lib/account.js
CHANGED
|
@@ -724,7 +724,11 @@ class Account {
|
|
|
724
724
|
return accountData;
|
|
725
725
|
}
|
|
726
726
|
|
|
727
|
-
|
|
727
|
+
// `reauthorized` marks an update that carries credentials supplied by an external caller,
|
|
728
|
+
// i.e. possible operator re-authorization. Only the public account-update API route sets it;
|
|
729
|
+
// every unattended writer (token renewal, client initialize(), invalidateAccessToken) leaves
|
|
730
|
+
// it false and can therefore never trigger the reconnect gate below.
|
|
731
|
+
async update(accountData, { reauthorized = false } = {}) {
|
|
728
732
|
let oldAccountData = await this.loadAccountData(accountData.account);
|
|
729
733
|
|
|
730
734
|
if (accountData.oauth2?.provider) {
|
|
@@ -864,13 +868,17 @@ class Account {
|
|
|
864
868
|
|
|
865
869
|
// When OAuth2 credentials are re-authorized for an account that is currently in a
|
|
866
870
|
// non-operational error state, trigger a full reconnect so syncing resumes without a
|
|
867
|
-
// manual "Reconnect".
|
|
868
|
-
//
|
|
869
|
-
//
|
|
870
|
-
//
|
|
871
|
+
// manual "Reconnect".
|
|
872
|
+
//
|
|
873
|
+
// Requires explicit `reauthorized` intent from the caller. Account state cannot be used
|
|
874
|
+
// to infer it: unattended token renewal persists through update() as well, and it runs
|
|
875
|
+
// while the stored state is still the error state, so a state-only gate re-fired on every
|
|
876
|
+
// renewal and dispatched cmd:'reconnect'. That rebuilt the client, discarding its backoff,
|
|
877
|
+
// and invalidateAccessToken() forced the next cycle to renew again - latching a reconnect
|
|
878
|
+
// loop that pinned the CPU at ~100%.
|
|
871
879
|
if (
|
|
880
|
+
reauthorized &&
|
|
872
881
|
!reconnectRequested &&
|
|
873
|
-
'oauth2' in accountData &&
|
|
874
882
|
accountData.oauth2?.accessToken &&
|
|
875
883
|
(accountData.oauth2.accessToken !== oldAccountData.oauth2?.accessToken ||
|
|
876
884
|
accountData.oauth2.refreshToken !== oldAccountData.oauth2?.refreshToken) &&
|
|
@@ -319,7 +319,10 @@ async function init(args) {
|
|
|
319
319
|
// Validate delegation fields are only used with OAuth2 provider
|
|
320
320
|
validateDelegationFields(request.payload);
|
|
321
321
|
|
|
322
|
-
|
|
322
|
+
// Credentials in this payload came from an API client, so a credential change here
|
|
323
|
+
// can mean the account was re-authorized - the only caller allowed to arm the
|
|
324
|
+
// reconnect gate in update().
|
|
325
|
+
return await accountObject.update(request.payload, { reauthorized: true });
|
|
323
326
|
} catch (err) {
|
|
324
327
|
handleError(request, err);
|
|
325
328
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const Joi = require('joi');
|
|
4
|
+
const Boom = require('@hapi/boom');
|
|
4
5
|
const { redis } = require('../db');
|
|
5
6
|
const { Account } = require('../account');
|
|
6
7
|
const getSecret = require('../get-secret');
|
|
@@ -69,6 +70,18 @@ async function init(args) {
|
|
|
69
70
|
});
|
|
70
71
|
|
|
71
72
|
try {
|
|
73
|
+
// Nothing invalidates an access token once it is minted, so a token handed to an
|
|
74
|
+
// anonymous caller keeps working indefinitely. This route normally requires a real
|
|
75
|
+
// credential (`auth: {strategy: 'api-token', mode: 'required'}`) and a caller
|
|
76
|
+
// presenting one is trusted, but the `disableTokens` setting rewrites a
|
|
77
|
+
// credential-less request to `access_token=preauth` and the strategy accepts it,
|
|
78
|
+
// marking the credentials `{preauth: true}`. That anonymous caller must never mint a
|
|
79
|
+
// lasting token - whether or not an admin password happens to be set - so refuse it
|
|
80
|
+
// here (headless provisioning uses the CLI or EENGINE_PREPARED_TOKEN, not this route).
|
|
81
|
+
if (request.auth.credentials?.preauth) {
|
|
82
|
+
throw Boom.forbidden('Can not provision an access token for an unauthenticated request');
|
|
83
|
+
}
|
|
84
|
+
|
|
72
85
|
// throws if account does not exist
|
|
73
86
|
await accountObject.loadAccountData();
|
|
74
87
|
|
package/lib/consts.js
CHANGED
|
@@ -7,19 +7,6 @@ if (!process.env.EE_ENV_LOADED) {
|
|
|
7
7
|
process.env.EE_ENV_LOADED = 'true';
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
const fs = require('fs');
|
|
11
|
-
const Path = require('path');
|
|
12
|
-
let SYSTEM_SPECIFIC_CONSTS = {};
|
|
13
|
-
|
|
14
|
-
try {
|
|
15
|
-
const systemEnvBuf = fs.readFileSync(Path.join(__dirname, '..', 'system.env'));
|
|
16
|
-
if (systemEnvBuf && systemEnvBuf.length) {
|
|
17
|
-
SYSTEM_SPECIFIC_CONSTS = dotenv.parse(systemEnvBuf);
|
|
18
|
-
}
|
|
19
|
-
} catch (err) {
|
|
20
|
-
// can safely ignore
|
|
21
|
-
}
|
|
22
|
-
|
|
23
10
|
module.exports = {
|
|
24
11
|
MESSAGE_NEW_NOTIFY: 'messageNew',
|
|
25
12
|
MESSAGE_NEW_DESCRIPTION: 'New Email - A new email is found in a folder (new email)',
|
|
@@ -160,6 +147,21 @@ module.exports = {
|
|
|
160
147
|
|
|
161
148
|
MAX_BACKOFF_DELAY: 10 * 60 * 1000, // 10 min
|
|
162
149
|
|
|
150
|
+
// Phantom folder handling: a folder that is listed but repeatedly rejects
|
|
151
|
+
// SELECT (e.g. a Dovecot shared namespace root without \Noselect) is
|
|
152
|
+
// treated like \Noselect after this many consecutive failures instead of
|
|
153
|
+
// re-attempting the SELECT on every sync pass, and is re-probed after the
|
|
154
|
+
// interval passes or its STATUS counters change
|
|
155
|
+
PHANTOM_SELECT_FAIL_THRESHOLD: 3,
|
|
156
|
+
PHANTOM_REPROBE_INTERVAL: 6 * 3600 * 1000, // 6 hours
|
|
157
|
+
|
|
158
|
+
// A connection that survives this long has proven itself stable: an
|
|
159
|
+
// unexpected close after this age reconnects immediately and resets the
|
|
160
|
+
// close-triggered reconnection backoff. Closes of younger connections are
|
|
161
|
+
// throttled - a server that accepts the full connection setup and then
|
|
162
|
+
// drops the connection would otherwise cause an unthrottled login loop
|
|
163
|
+
STABLE_CONNECTION_TIME: 5 * 60 * 1000, // 5 min
|
|
164
|
+
|
|
163
165
|
MAX_INLINE_ATTACHMENT_SIZE: 2 * 1024 * 1024,
|
|
164
166
|
|
|
165
167
|
TOTP_WINDOW_SIZE: 6,
|
|
@@ -281,15 +283,3 @@ module.exports = {
|
|
|
281
283
|
}
|
|
282
284
|
}
|
|
283
285
|
};
|
|
284
|
-
|
|
285
|
-
if (SYSTEM_SPECIFIC_CONSTS && typeof SYSTEM_SPECIFIC_CONSTS === 'object') {
|
|
286
|
-
for (let key of Object.keys(SYSTEM_SPECIFIC_CONSTS)) {
|
|
287
|
-
let value = SYSTEM_SPECIFIC_CONSTS[key];
|
|
288
|
-
switch (key) {
|
|
289
|
-
case 'EE_DOCKER_LEGACY':
|
|
290
|
-
value = !!/^(y|true|[1-9])/i.test(value);
|
|
291
|
-
break;
|
|
292
|
-
}
|
|
293
|
-
module.exports[key] = value;
|
|
294
|
-
}
|
|
295
|
-
}
|
package/lib/delivery-error.js
CHANGED
|
@@ -6,9 +6,12 @@
|
|
|
6
6
|
// the BullMQ submit worker (workers/submit.js connects to Redis and expects a
|
|
7
7
|
// worker-thread parentPort at require time).
|
|
8
8
|
|
|
9
|
-
// Nodemailer/SMTP error codes that represent permanent failures
|
|
10
|
-
//
|
|
11
|
-
//
|
|
9
|
+
// Nodemailer/SMTP error codes that represent permanent failures when the error does NOT also carry a
|
|
10
|
+
// transient (4xx) SMTP reply code. nodemailer stamps these on hard failures (bad credentials, a
|
|
11
|
+
// malformed envelope the server never even replied to, TLS/protocol mismatch) that recur on every
|
|
12
|
+
// retry, so the job is discarded instead of retried. Note that nodemailer also stamps
|
|
13
|
+
// EAUTH/EENVELOPE/EMESSAGE on *transient* 4xx replies (e.g. a "450 greylisted" RCPT TO), which is
|
|
14
|
+
// why isPermanentDeliveryError() consults the SMTP reply code BEFORE this set.
|
|
12
15
|
const NON_RETRYABLE_CODES = new Set([
|
|
13
16
|
'EAUTH', // authentication failed
|
|
14
17
|
'ENOAUTH', // no credentials provided
|
|
@@ -22,13 +25,24 @@ const NON_RETRYABLE_CODES = new Set([
|
|
|
22
25
|
/**
|
|
23
26
|
* Determines whether a delivery error is permanent (must not be retried).
|
|
24
27
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
28
|
+
* The SMTP-reply rule is keyed on nodemailer's `responseCode`, NOT on `statusCode`. Only a real SMTP
|
|
29
|
+
* reply puts a code in `responseCode` (base-client.js copies it into `statusCode` for the API and
|
|
30
|
+
* webhook payloads, which is why the two look interchangeable and are not). Across the rest of the
|
|
31
|
+
* codebase a 5xx `statusCode` overwhelmingly means the opposite of a rejected message: 503 "no active
|
|
32
|
+
* handler", 504 inter-thread RPC timeouts, 500 Redis lock failures, and every API transport's
|
|
33
|
+
* passthrough of the provider's HTTP status. Reading that field as an SMTP verdict silently discarded
|
|
34
|
+
* queued mail that nothing was wrong with. `responseCode` is forwarded across the worker-thread RPC
|
|
35
|
+
* hop explicitly (see lib/worker-rpc-error.js) so this branch actually fires in production.
|
|
36
|
+
*
|
|
37
|
+
* When a real SMTP reply is present it decides on its own: per RFC 5321 a 4yz reply is a TRANSIENT
|
|
38
|
+
* negative completion ("try again later", e.g. greylisting) and only 5yz is permanent. nodemailer
|
|
39
|
+
* tags envelope/message/auth rejections with EENVELOPE/EMESSAGE/EAUTH regardless of the reply class,
|
|
40
|
+
* so the reply code has to be consulted BEFORE the code allowlist - otherwise a soft 4xx (or a 503)
|
|
41
|
+
* would be discarded as if it were a hard rejection. The code allowlist is the fallback for failures
|
|
42
|
+
* that carry no server reply at all (missing credentials, TLS/protocol mismatch).
|
|
29
43
|
*
|
|
30
44
|
* @param {Object} err - Error thrown during submission
|
|
31
|
-
* @param {Number} [err.
|
|
45
|
+
* @param {Number} [err.responseCode] - SMTP reply code, set by nodemailer on real SMTP failures
|
|
32
46
|
* @param {String} [err.code] - Nodemailer error code
|
|
33
47
|
* @returns {Boolean} True if the error should never be retried
|
|
34
48
|
*/
|
|
@@ -36,9 +50,18 @@ function isPermanentDeliveryError(err) {
|
|
|
36
50
|
if (!err) {
|
|
37
51
|
return false;
|
|
38
52
|
}
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
|
|
53
|
+
|
|
54
|
+
const smtpResponseCode = Number(err.responseCode);
|
|
55
|
+
if (smtpResponseCode) {
|
|
56
|
+
// A real SMTP reply decides on its own: 5xx is permanent, everything else (transient 4xx, or
|
|
57
|
+
// an unexpected 2xx/3xx) is retryable. 503 is carved out and left retryable on purpose -
|
|
58
|
+
// discarding a message the server might still accept loses mail, while retrying a genuinely
|
|
59
|
+
// permanent 503 only wastes a bounded number of attempts.
|
|
60
|
+
return smtpResponseCode >= 500 && smtpResponseCode !== 503;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// No SMTP reply at all: fall back to the nodemailer error code.
|
|
64
|
+
return NON_RETRYABLE_CODES.has(err.code);
|
|
42
65
|
}
|
|
43
66
|
|
|
44
67
|
/**
|
|
@@ -1907,7 +1907,7 @@ class GmailClient extends BaseClient {
|
|
|
1907
1907
|
}
|
|
1908
1908
|
// Pass `call` so Account.update() can dispatch a reconnect back to this worker when
|
|
1909
1909
|
// OAuth credentials are re-authorized for an account in an error state (same channel the
|
|
1910
|
-
// IMAP path uses).
|
|
1910
|
+
// IMAP path uses).
|
|
1911
1911
|
this.accountObject = new Account({ redis: this.redis, account: this.account, secret: await getSecret(), call: msg => this.call(msg) });
|
|
1912
1912
|
return this.accountObject;
|
|
1913
1913
|
}
|