emailengine-app 2.79.7 → 2.79.8
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/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +17 -0
- package/DOCKER_DEPLOYMENT.md +2 -0
- package/bin/emailengine.js +29 -13
- package/config/default.toml +13 -3
- package/data/google-crawlers.json +7 -1
- package/docker-compose.yml +12 -3
- package/install.sh +2 -0
- package/lib/api-routes/account-routes.js +14 -3
- package/lib/api-routes/mailbox-routes.js +4 -1
- package/lib/api-routes/message-routes.js +6 -5
- package/lib/api-routes/outbox-routes.js +7 -4
- package/lib/api-routes/settings-routes.js +34 -25
- package/lib/api-routes/stats-routes.js +8 -1
- package/lib/api-routes/submit-routes.js +2 -1
- package/lib/api-routes/template-routes.js +3 -2
- package/lib/bounce-detect.js +45 -0
- package/lib/consts.js +5 -1
- package/lib/egress-filter.js +39 -4
- package/lib/email-client/base-client.js +274 -24
- package/lib/email-client/gmail/gmail-api.js +15 -7
- package/lib/email-client/gmail-client.js +121 -64
- package/lib/email-client/imap/mailbox.js +18 -59
- package/lib/email-client/imap-client.js +53 -29
- package/lib/email-client/notification-handler.js +11 -2
- package/lib/email-client/outlook/graph-api.js +106 -90
- package/lib/email-client/outlook-client.js +222 -106
- package/lib/generate-text-preview.js +10 -5
- package/lib/headers-rewriter.js +1 -1
- package/lib/llm-pre-process.js +4 -1
- package/lib/mcp/json-schema.js +50 -2
- package/lib/outbox.js +22 -5
- package/lib/pre-process.js +4 -1
- package/lib/rewrite-text-nodes.js +12 -1
- package/lib/schemas.js +27 -5
- package/lib/settings.js +19 -1
- package/lib/sso.js +13 -3
- package/lib/submit-progress.js +29 -0
- package/lib/templates.js +11 -0
- package/lib/tools.js +96 -53
- package/lib/ui-routes/account-routes.js +70 -11
- package/lib/ui-routes/admin-config-routes.js +7 -21
- package/lib/ui-routes/admin-entities-routes.js +42 -12
- package/lib/ui-routes/auth-routes.js +87 -28
- package/lib/ui-routes/dashboard-routes.js +1 -1
- package/lib/ui-routes/internals-routes.js +2 -0
- package/lib/ui-routes/mcp-consent-routes.js +5 -2
- package/lib/ui-routes/network-config-routes.js +2 -2
- package/lib/ui-routes/oauth-config-routes.js +12 -1
- package/lib/ui-routes/route-helpers.js +41 -6
- package/lib/ui-routes/settings-page.js +10 -0
- package/lib/ui-routes/suppression-list-routes.js +16 -5
- package/lib/ui-routes/unsubscribe-routes.js +22 -3
- package/lib/webhooks.js +14 -2
- package/package.json +11 -11
- package/sbom.json +1 -1
- package/server.js +63 -35
- package/static/css/flyonui.css +1 -1
- package/static/licenses.html +17 -17
- package/translations/messages.pot +49 -49
- package/views/account/passkeys.hbs +8 -0
- package/views/account/password.hbs +11 -0
- package/views/account/security.hbs +18 -7
- package/views/accounts/account.hbs +6 -1
- package/views/accounts/register/imap-server.hbs +10 -2
- package/views/config/ai.hbs +2 -0
- package/views/config/branding.hbs +2 -0
- package/views/config/email-processing.hbs +2 -0
- package/views/config/imap-proxy.hbs +2 -0
- package/views/config/logging.hbs +3 -1
- package/views/config/mcp.hbs +2 -0
- package/views/config/network.hbs +2 -0
- package/views/config/oauth/app.hbs +2 -2
- package/views/config/security.hbs +2 -0
- package/views/config/service.hbs +2 -0
- package/views/config/smtp.hbs +2 -0
- package/views/config/webhooks.hbs +2 -0
- package/views/error.hbs +6 -0
- package/views/layout/app.hbs +6 -3
- package/views/layout/login.hbs +1 -1
- package/views/layout/prompt.hbs +1 -1
- package/views/layout/public.hbs +1 -1
- package/views/legal.hbs +1 -1
- package/views/partials/filter_editor_js.hbs +1 -1
- package/views/partials/oauth_form.hbs +5 -5
- package/views/partials/ui/env-managed-alert.hbs +19 -0
- package/views/partials/webhook_form.hbs +1 -1
- package/views/unsubscribe.hbs +6 -0
- package/workers/api.js +137 -63
- package/workers/imap.js +32 -3
- package/workers/smtp.js +7 -0
- package/workers/submit.js +25 -1
- package/workers/webhooks.js +13 -17
- package/lib/reconnection-manager.js +0 -106
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.79.8](https://github.com/postalsys/emailengine/compare/v2.79.7...v2.79.8) (2026-09-02)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **admin-ui:** keep form input on a failed save and fix the misrouted webhook form ([e01d8a2](https://github.com/postalsys/emailengine/commit/e01d8a2021fde0e0122b5dc98a8f539128c8a4af))
|
|
9
|
+
* **api:** keep template formats on update and answer malformed ids with 4xx ([3eb9868](https://github.com/postalsys/emailengine/commit/3eb9868fd5f2639e1ad40a26ec2e7a91e308c2e3))
|
|
10
|
+
* **auth:** secure every API worker on the first password and tighten the admin second factor ([0adb3b4](https://github.com/postalsys/emailengine/commit/0adb3b46baf29d7125a81b9ec61a7e091b7826da))
|
|
11
|
+
* **config:** stop prepared configuration from surprising operators on restart ([0f4ab9a](https://github.com/postalsys/emailengine/commit/0f4ab9ab78e4fa4e648c9384c6d0a7fc8b80a937))
|
|
12
|
+
* **delivery:** treat delay notices as delays and unwrap embedded IPv4 in the egress filter ([37ccc5c](https://github.com/postalsys/emailengine/commit/37ccc5c2ccab1c5ca301fec482d2e09cb2c9b352))
|
|
13
|
+
* **deps:** update imapflow to 1.7.8 for the download teardown worker deaths ([18d68b2](https://github.com/postalsys/emailengine/commit/18d68b29893c20a59ccec91526e4e5a420e73c0d))
|
|
14
|
+
* **deps:** update nodemailer to 9.1.1 across the dependency tree ([e67641e](https://github.com/postalsys/emailengine/commit/e67641e54c655a4a71b61919ed4098deb908b2b5))
|
|
15
|
+
* **email-client:** close the gaps between the IMAP, Gmail and Graph clients ([47f4623](https://github.com/postalsys/emailengine/commit/47f4623ac0ef3f483fbebbb33d935e141f17d4b4))
|
|
16
|
+
* **submit:** do not send a message again when a stalled job is re-run ([91c7c00](https://github.com/postalsys/emailengine/commit/91c7c0045d858b987a18a92afd934afdf8b0f3d1))
|
|
17
|
+
* **tracking:** route a text-node decoder failure to the rewrite's rejection path ([13e9f9f](https://github.com/postalsys/emailengine/commit/13e9f9fd71a5933677adb428d17c77af3a0ee691))
|
|
18
|
+
* **webhooks:** send Basic-auth credentials verbatim and deliver each attempt once ([c6d1242](https://github.com/postalsys/emailengine/commit/c6d1242b737bc215d35284f70493afa064b8cde7))
|
|
19
|
+
|
|
3
20
|
## [2.79.7](https://github.com/postalsys/emailengine/compare/v2.79.6...v2.79.7) (2026-08-31)
|
|
4
21
|
|
|
5
22
|
|
package/DOCKER_DEPLOYMENT.md
CHANGED
|
@@ -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
|
package/bin/emailengine.js
CHANGED
|
@@ -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
|
|
package/config/default.toml
CHANGED
|
@@ -4,24 +4,33 @@ 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
|
-
|
|
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
|
-
#
|
|
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
|
+
# Serve the API over HTTPS by pointing at a certificate and key
|
|
31
|
+
#[api.tls]
|
|
32
|
+
#certPath = "/path/to/cert.pem"
|
|
33
|
+
#keyPath = "/path/to/key.pem"
|
|
25
34
|
|
|
26
35
|
[smtp]
|
|
27
36
|
enabled = false
|
|
@@ -30,6 +39,7 @@ host = "127.0.0.1"
|
|
|
30
39
|
secret = "" # client password, if not set allows any password
|
|
31
40
|
proxy = false # Set to true if using HAProxy with send-proxy option
|
|
32
41
|
#maxMessageSize = "25M" # maximum message size accepted by SMTP server (default: 25MB)
|
|
42
|
+
#maxClients = 100 # concurrent SMTP server connections; excess connections are refused with a 421 (default: 100)
|
|
33
43
|
|
|
34
44
|
[documentStore]
|
|
35
45
|
# Deprecated Document Store (ElasticSearch) feature. Disabled by default; the worker and
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"creationTime": "2026-
|
|
2
|
+
"creationTime": "2026-09-01T14:46:55.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
|
},
|
package/docker-compose.yml
CHANGED
|
@@ -23,17 +23,26 @@ services:
|
|
|
23
23
|
- emailengine-network
|
|
24
24
|
environment:
|
|
25
25
|
# Configuration via environment variables
|
|
26
|
-
# For full list see https://
|
|
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
|
|
32
|
-
|
|
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
|
|
@@ -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
|
-
|
|
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
|
|
|
@@ -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
|
-
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
864
|
+
message: messageIdSchema.required()
|
|
864
865
|
}).label('MessageDelete')
|
|
865
866
|
},
|
|
866
867
|
response: {
|
|
@@ -151,9 +151,7 @@ async function init(args) {
|
|
|
151
151
|
|
|
152
152
|
async handler(request) {
|
|
153
153
|
try {
|
|
154
|
-
return {
|
|
155
|
-
deleted: await outbox.del({ queueId: request.params.queueId, logger })
|
|
156
|
-
};
|
|
154
|
+
return await outbox.del({ queueId: request.params.queueId, logger });
|
|
157
155
|
} catch (err) {
|
|
158
156
|
handleError(request, err);
|
|
159
157
|
}
|
|
@@ -191,7 +189,12 @@ async function init(args) {
|
|
|
191
189
|
|
|
192
190
|
response: {
|
|
193
191
|
schema: Joi.object({
|
|
194
|
-
deleted: Joi.boolean().truthy('Y', 'true', '1').falsy('N', 'false', 0).default(true).description('Was the message deleted')
|
|
192
|
+
deleted: Joi.boolean().truthy('Y', 'true', '1').falsy('N', 'false', 0).default(true).description('Was the message deleted'),
|
|
193
|
+
locked: Joi.boolean()
|
|
194
|
+
.example(true)
|
|
195
|
+
.description(
|
|
196
|
+
'Present when the message was not deleted because a delivery attempt is running for it right now. Retry once the attempt has finished'
|
|
197
|
+
)
|
|
195
198
|
}).label('DeleteOutboxEntryResponse'),
|
|
196
199
|
failAction: 'log'
|
|
197
200
|
}
|
|
@@ -15,7 +15,7 @@ const { settingsSchema, settingsQuerySchema, apiResponses, ENUM_DESCRIPTIONS } =
|
|
|
15
15
|
// not part of the stored settings.
|
|
16
16
|
const settingsOutputSchema = {};
|
|
17
17
|
for (let key of Object.keys(settingsSchema)) {
|
|
18
|
-
if (settings.
|
|
18
|
+
if (settings.secretKeys.includes(key)) {
|
|
19
19
|
settingsOutputSchema[key] = Joi.boolean()
|
|
20
20
|
.allow(null)
|
|
21
21
|
.example(true)
|
|
@@ -40,32 +40,37 @@ async function init(args) {
|
|
|
40
40
|
|
|
41
41
|
async handler(request) {
|
|
42
42
|
let values = {};
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (key
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
43
|
+
try {
|
|
44
|
+
for (let key of Object.keys(request.query)) {
|
|
45
|
+
if (request.query[key]) {
|
|
46
|
+
if (key === 'eventTypes') {
|
|
47
|
+
values[key] = Object.keys(consts)
|
|
48
|
+
.filter(key => /_NOTIFY?/.test(key))
|
|
49
|
+
.map(key => consts[key]);
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
51
52
|
|
|
52
|
-
|
|
53
|
+
let value = await settings.get(key);
|
|
53
54
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
if (settings.secretKeys.includes(key)) {
|
|
56
|
+
// do not reveal secret values
|
|
57
|
+
// instead show boolean value true if value is set, or false if it's not
|
|
58
|
+
value = value ? true : false;
|
|
59
|
+
}
|
|
59
60
|
|
|
60
|
-
|
|
61
|
+
values[key] = value;
|
|
62
|
+
}
|
|
61
63
|
}
|
|
64
|
+
} catch (err) {
|
|
65
|
+
handleError(request, err);
|
|
62
66
|
}
|
|
63
67
|
|
|
64
|
-
// The global equivalents of the credential-bearing account fields.
|
|
65
|
-
// covers
|
|
66
|
-
// webhooks and webhooksCustomHeaders are
|
|
67
|
-
//
|
|
68
|
-
//
|
|
68
|
+
// The global equivalents of the credential-bearing account fields. secretKeys above
|
|
69
|
+
// covers the values that are hidden behind a boolean, which is not the same set:
|
|
70
|
+
// proxyUrl, httpProxyUrl, webhooks and webhooksCustomHeaders are returned as values
|
|
71
|
+
// (they are useful to read back) and used to be returned in full, so this endpoint
|
|
72
|
+
// disclosed exactly what the account getters were masking. It sits in the
|
|
73
|
+
// never-grantable admin group, so no narrowed token reaches it - but leaving the
|
|
69
74
|
// asymmetry here is how the next reader learns the wrong pattern.
|
|
70
75
|
maskSecrets(values);
|
|
71
76
|
|
|
@@ -141,12 +146,16 @@ async function init(args) {
|
|
|
141
146
|
}
|
|
142
147
|
} catch (err) {
|
|
143
148
|
handleError(request, err);
|
|
149
|
+
} finally {
|
|
150
|
+
// Broadcast to all workers (including this one); each reloads its HTTP proxy agent
|
|
151
|
+
// via the 'settings' message handler, so no inline reload is needed here. Only the
|
|
152
|
+
// keys that were actually written: a skipped masked echo must not trigger reloads
|
|
153
|
+
// either. In a finally because the keys are written one at a time: when a later
|
|
154
|
+
// key fails, the earlier ones are already stored and the other workers still have
|
|
155
|
+
// to reload for them, or they keep running on settings Redis no longer holds.
|
|
156
|
+
notify('settings', applied);
|
|
144
157
|
}
|
|
145
158
|
|
|
146
|
-
// Broadcast to all workers (including this one); each reloads its HTTP proxy agent via
|
|
147
|
-
// the 'settings' message handler, so no inline reload is needed here. Only the keys
|
|
148
|
-
// that were actually written: a skipped masked echo must not trigger reloads either.
|
|
149
|
-
notify('settings', applied);
|
|
150
159
|
return { updated: Object.keys(applied) };
|
|
151
160
|
},
|
|
152
161
|
options: {
|
|
@@ -5,6 +5,7 @@ const { redis } = require('../db');
|
|
|
5
5
|
const { failAction, getStats } = require('../tools');
|
|
6
6
|
const { MAX_DAYS_STATS } = require('../consts');
|
|
7
7
|
const { apiResponses } = require('../schemas');
|
|
8
|
+
const { handleError } = require('./route-helpers');
|
|
8
9
|
const packageData = require('../../package.json');
|
|
9
10
|
|
|
10
11
|
async function init(args) {
|
|
@@ -15,7 +16,13 @@ async function init(args) {
|
|
|
15
16
|
path: '/v1/stats',
|
|
16
17
|
|
|
17
18
|
async handler(request) {
|
|
18
|
-
|
|
19
|
+
try {
|
|
20
|
+
return await getStats(redis, call, request.query.seconds);
|
|
21
|
+
} catch (err) {
|
|
22
|
+
// The metrics come from a main-thread RPC, so a timeout there carries its own
|
|
23
|
+
// status code, which the shared handler keeps instead of a generic 500
|
|
24
|
+
handleError(request, err);
|
|
25
|
+
}
|
|
19
26
|
},
|
|
20
27
|
|
|
21
28
|
options: {
|
|
@@ -16,6 +16,7 @@ const {
|
|
|
16
16
|
idempotencyKeySchema,
|
|
17
17
|
headerTimeoutSchema,
|
|
18
18
|
accountIdSchema,
|
|
19
|
+
messageIdSchema,
|
|
19
20
|
templateSchemas,
|
|
20
21
|
settingsSchema,
|
|
21
22
|
ipSchema,
|
|
@@ -622,7 +623,7 @@ async function init(args) {
|
|
|
622
623
|
|
|
623
624
|
params: Joi.object({
|
|
624
625
|
account: accountIdSchema.required(),
|
|
625
|
-
message:
|
|
626
|
+
message: messageIdSchema.required().description('Message ID of the draft')
|
|
626
627
|
}),
|
|
627
628
|
|
|
628
629
|
headers: submitHeadersSchema,
|
|
@@ -177,11 +177,12 @@ async function init(args) {
|
|
|
177
177
|
.example('Something about the template')
|
|
178
178
|
.description('Optional description of the template')
|
|
179
179
|
.label('TemplateDescription'),
|
|
180
|
+
// No default on purpose: the handler copies every present key over the stored
|
|
181
|
+
// metadata, so a defaulted format would turn any partial update into "html"
|
|
180
182
|
format: Joi.string()
|
|
181
183
|
.empty('')
|
|
182
184
|
.valid('html', 'markdown')
|
|
183
|
-
.
|
|
184
|
-
.description('Markup language for HTML ("html" or "markdown")')
|
|
185
|
+
.description('Markup language for HTML ("html" or "markdown"). Leave out to keep the stored value')
|
|
185
186
|
.label('TemplateUpdateFormat'),
|
|
186
187
|
content: Joi.object({
|
|
187
188
|
subject: templateSchemas.subject,
|
package/lib/bounce-detect.js
CHANGED
|
@@ -28,6 +28,35 @@ const { pushHeaderValue } = require('./utils/header-map');
|
|
|
28
28
|
const simpleParser = require('mailparser').simpleParser;
|
|
29
29
|
const { toCamelCase } = require('./utils/to-camel-case');
|
|
30
30
|
|
|
31
|
+
// Wording of a notice that reports a delay rather than a failure. Sendmail and qmail-style MTAs
|
|
32
|
+
// send these as plain text, with the same "<user@example.com>:" recipient block a bounce carries
|
|
33
|
+
const DELAY_NOTICE_RE =
|
|
34
|
+
/WARNING MESSAGE ONLY|DO NOT NEED TO RESEND|has not yet been delivered|will keep trying|delivery attempts will continue|delivery (?:is|has been) delayed/i;
|
|
35
|
+
|
|
36
|
+
// Wording that says the MTA gave up. A final bounce often quotes the last temporary reply the
|
|
37
|
+
// remote host gave ("Sorry, I wasn't able to establish an SMTP connection. (#4.4.1)" followed by
|
|
38
|
+
// "I'm not going to try again"), so a 4.x.x status on its own does not make a notice a delay
|
|
39
|
+
const GAVE_UP_RE = /permanent error|given up|not going to try again|retry timeout exceeded|will not be retried|could not be delivered/i;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Tells whether a notice the text heuristics matched reports a delay rather than a failure
|
|
43
|
+
*
|
|
44
|
+
* @param {string} text - Body text the heuristics ran over
|
|
45
|
+
* @param {Object} [response] - The response the heuristics extracted
|
|
46
|
+
* @returns {Boolean} True for a temporary failure the MTA is still retrying
|
|
47
|
+
*/
|
|
48
|
+
function isDelayNotice(text, response) {
|
|
49
|
+
if (DELAY_NOTICE_RE.test(text)) {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
let status = (response && response.status) || '';
|
|
54
|
+
let message = (response && response.message) || '';
|
|
55
|
+
let temporary = /^4\./.test(status) || /^4\d{2}[\s-]/.test(message);
|
|
56
|
+
|
|
57
|
+
return temporary && !GAVE_UP_RE.test(text);
|
|
58
|
+
}
|
|
59
|
+
|
|
31
60
|
/**
|
|
32
61
|
* Splits the address type off a DSN value, eg. "rfc822; user@example.com"
|
|
33
62
|
*
|
|
@@ -484,6 +513,10 @@ async function bounceDetect(sourceStream) {
|
|
|
484
513
|
}
|
|
485
514
|
}
|
|
486
515
|
|
|
516
|
+
// What the structured parts said, if anything; the text heuristics below only fill gaps, and
|
|
517
|
+
// only a claim they made is reconsidered at the end
|
|
518
|
+
let structuredAction = result.action;
|
|
519
|
+
|
|
487
520
|
// Extract text content for pattern matching
|
|
488
521
|
let text = (parsed.text || '').toString();
|
|
489
522
|
|
|
@@ -928,6 +961,18 @@ async function bounceDetect(sourceStream) {
|
|
|
928
961
|
}
|
|
929
962
|
}
|
|
930
963
|
|
|
964
|
+
// The heuristics above claim 'failed' for any recipient block or quoted reply they recognize,
|
|
965
|
+
// but a delay notice has the same shape: a Sendmail-style "THIS IS A WARNING MESSAGE ONLY"
|
|
966
|
+
// carries a "<user@example.com>: ... (#4.4.1)" block, and a plain-text notice may quote a
|
|
967
|
+
// "said: 450 4.2.1 ..." reply. A delay reported as a DSN never gets here (it is applied as a
|
|
968
|
+
// delivery report first, see applyDeliveryReport), so only a claim the heuristics made is
|
|
969
|
+
// reconsidered. The action is cleared rather than set to 'delayed': every caller treats a set
|
|
970
|
+
// action as a bounce to store and to fire emailBounce for, and a message the remote host is
|
|
971
|
+
// still retrying is not one
|
|
972
|
+
if (!structuredAction && result.action === 'failed' && isDelayNotice(text, result.response)) {
|
|
973
|
+
delete result.action;
|
|
974
|
+
}
|
|
975
|
+
|
|
931
976
|
// Include parsed message headers in the result
|
|
932
977
|
result.messageHeaders = parsedMessageHeaders || null;
|
|
933
978
|
|
package/lib/consts.js
CHANGED
|
@@ -204,7 +204,11 @@ module.exports = {
|
|
|
204
204
|
// history cursor only moves after processing completes
|
|
205
205
|
GMAIL_MAX_HISTORY_ENTRY_ATTEMPTS: 3,
|
|
206
206
|
|
|
207
|
-
|
|
207
|
+
// Time steps accepted either side of the current one when verifying a TOTP code: 1 means the
|
|
208
|
+
// current code plus the previous and the next (a 90-second span). RFC 6238 suggests at most
|
|
209
|
+
// one step - it absorbs the clock drift a phone accumulates between network syncs, while
|
|
210
|
+
// every extra step is another valid six-digit code for a guess to land on
|
|
211
|
+
TOTP_WINDOW_SIZE: 1,
|
|
208
212
|
|
|
209
213
|
WEBAUTHN_CHALLENGE_TTL: 300, // 5 minutes
|
|
210
214
|
MAX_PASSKEYS_PER_USER: 20,
|