emailengine-app 2.83.2 → 2.84.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/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +20 -0
- package/README.md +1 -1
- package/SECURITY.md +126 -47
- package/data/google-crawlers.json +1 -1
- package/lib/api-routes/outbox-routes.js +132 -9
- package/lib/api-routes/permission-map.js +11 -1
- package/lib/consts.js +0 -4
- package/lib/email-client/imap/idle-settings.js +44 -0
- package/lib/email-client/imap/mailbox.js +19 -7
- package/lib/email-client/imap-client.js +3 -21
- package/lib/enum-descriptions.js +7 -0
- package/lib/export.js +2 -6
- package/lib/field-usage.js +4 -0
- package/lib/handlebars-helpers.js +4 -0
- package/lib/outbox.js +338 -10
- package/lib/queue-browser/definitions.js +132 -0
- package/lib/queue-browser/format.js +387 -0
- package/lib/queue-browser/index.js +568 -0
- package/lib/queue-job-actions.js +75 -0
- package/lib/queue-retention.js +53 -1
- package/lib/routes-ui.js +5 -0
- package/lib/schemas.js +42 -2
- package/lib/security-headers.js +2 -24
- package/lib/token-permission-view.js +1 -1
- package/lib/ui-routes/account-routes.js +6 -0
- package/lib/ui-routes/imap-idle-field.js +42 -0
- package/lib/ui-routes/queue-routes.js +371 -0
- package/lib/utils/status-error.js +21 -0
- package/package.json +15 -17
- package/prepare-bundle-deps.sh +1 -1
- package/sbom.json +1 -1
- package/server.js +10 -0
- package/static/css/flyonui.css +1 -1
- package/static/css/src/app.tailwind.css +2 -0
- package/static/js/queues.js +117 -0
- package/static/licenses.html +122 -246
- package/translations/messages.pot +57 -42
- package/views/accounts/account.hbs +31 -0
- package/views/accounts/edit.hbs +2 -0
- package/views/config/service.hbs +1 -2
- package/views/dashboard.hbs +2 -2
- package/views/partials/queue_cell_account.hbs +20 -0
- package/views/partials/queue_cell_failure.hbs +6 -0
- package/views/partials/queue_clean_items.hbs +9 -0
- package/views/partials/queue_clean_modal.hbs +9 -0
- package/views/partials/queue_entry_actions.hbs +41 -0
- package/views/partials/queue_job_actions.hbs +15 -0
- package/views/partials/queue_pause_controls.hbs +18 -0
- package/views/partials/queue_retention_note.hbs +49 -0
- package/views/partials/queue_rows_export.hbs +58 -0
- package/views/partials/queue_rows_notify.hbs +73 -0
- package/views/partials/queue_rows_submit.hbs +70 -0
- package/views/partials/side_menu.hbs +1 -1
- package/views/partials/ui/tooltip.hbs +5 -3
- package/views/queues/index.hbs +104 -0
- package/views/queues/job.hbs +224 -0
- package/views/queues/queue.hbs +93 -0
- package/views/webhooks/webhook.hbs +3 -0
- package/workers/api.js +0 -4
- package/workers/submit.js +19 -5
- package/workers/webhooks.js +13 -0
- package/lib/api-routes/bull-board-routes.js +0 -56
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.84.0](https://github.com/postalsys/emailengine/compare/v2.83.2...v2.84.0) (2026-10-15)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **admin:** replace bull-board with an in-house queue browser ([4215616](https://github.com/postalsys/emailengine/commit/4215616552c92762212c021ab2c0768884aa487b))
|
|
9
|
+
* per-account IDLE restart interval (imap.maxIdleTime) ([25e5cb7](https://github.com/postalsys/emailengine/commit/25e5cb761d39a33304f9219dccad4f9bc0c336a6))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* **admin:** format the queue help panel and keep a leading kebab menu on the page ([ed51305](https://github.com/postalsys/emailengine/commit/ed513050da555d195ba9937a82f216bff053cd9e))
|
|
15
|
+
* **admin:** move a queue entry's actions to the page header and explain what the queues keep ([9ace194](https://github.com/postalsys/emailengine/commit/9ace19484818f6f0951bb53bbfb8ea0826a23f40))
|
|
16
|
+
* **admin:** post queue entry actions as plain forms ([e335331](https://github.com/postalsys/emailengine/commit/e335331a56c994f08c2e051444378d93e1cefa67))
|
|
17
|
+
* **admin:** say which bound decides the failed-entry count on the queue page ([7224cd7](https://github.com/postalsys/emailengine/commit/7224cd742cd3760bca46b4a748eb54bd73020ec8))
|
|
18
|
+
* **deps:** update bullmq to 6.3.15 ([b58b632](https://github.com/postalsys/emailengine/commit/b58b63233aa0aedad57c4816ad3d937089161e56))
|
|
19
|
+
* **deps:** update imapflow to 2.4.3 and dotenv to 18.0.8 ([c28955b](https://github.com/postalsys/emailengine/commit/c28955bbcedc20748745016fcec397e2603e85c3))
|
|
20
|
+
* **deps:** update nodemailer to 10.1.1, imapflow to 2.4.2 and libmime to 5.4.8 ([ff766dd](https://github.com/postalsys/emailengine/commit/ff766dd89ea1de9cdb72673cec14adb7c9bb90ff))
|
|
21
|
+
* skip DSN parsing when the message was expunged before it was downloaded ([44113d5](https://github.com/postalsys/emailengine/commit/44113d55fd2f89902536a3ef3074b9fa27a4838b))
|
|
22
|
+
|
|
3
23
|
## [2.83.2](https://github.com/postalsys/emailengine/compare/v2.83.1...v2.83.2) (2026-10-10)
|
|
4
24
|
|
|
5
25
|
|
package/README.md
CHANGED
|
@@ -142,7 +142,7 @@ EmailEngine relies on Redis as its data store. Redis stores everything in RAM, s
|
|
|
142
142
|
|
|
143
143
|
To diagnose problems:
|
|
144
144
|
|
|
145
|
-
1. **Check the job queues:**
|
|
145
|
+
1. **Check the job queues:** Open the queue browser at [http://127.0.0.1:3000/admin/queues](http://127.0.0.1:3000/admin/queues) (requires an admin session) to see what is waiting, running and failed in the webhook, submission and export queues.
|
|
146
146
|
2. **Scan Keyspace:** Run the following to group Redis keys by type and generate a report:
|
|
147
147
|
|
|
148
148
|
```bash
|
package/SECURITY.md
CHANGED
|
@@ -1,80 +1,159 @@
|
|
|
1
1
|
# Security Policy
|
|
2
2
|
|
|
3
|
-
EmailEngine is a self-hosted email integration platform
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
EmailEngine is a self-hosted email integration platform. It stores email account
|
|
4
|
+
credentials, proxies access to IMAP/SMTP, the Gmail API, and the Microsoft Graph
|
|
5
|
+
API, and serves a REST API and an admin web UI. We welcome responsible reports
|
|
6
|
+
of vulnerabilities that present a credible security risk to users. Please
|
|
7
|
+
distinguish security vulnerabilities from ordinary bugs, unusual edge cases, and
|
|
8
|
+
hardening suggestions.
|
|
7
9
|
|
|
8
10
|
## Supported Versions
|
|
9
11
|
|
|
10
|
-
Security fixes are released only against the latest version. We do not
|
|
11
|
-
patches to older
|
|
12
|
-
supported way to receive security updates.
|
|
12
|
+
Security fixes are released only against the latest major version. We do not
|
|
13
|
+
backport patches to older majors, so upgrading to the current release line is
|
|
14
|
+
the supported way to receive security updates.
|
|
13
15
|
|
|
14
16
|
| Version | Supported |
|
|
15
17
|
| ------- | ------------------ |
|
|
16
18
|
| 2.x | :white_check_mark: |
|
|
17
19
|
| < 2.0 | :x: |
|
|
18
20
|
|
|
19
|
-
If you are on an older
|
|
21
|
+
If you are on an older major, please upgrade. See the release notes at
|
|
20
22
|
<https://github.com/postalsys/emailengine/releases> before updating.
|
|
21
23
|
|
|
24
|
+
## What Qualifies as a Security Vulnerability
|
|
25
|
+
|
|
26
|
+
A security report should identify a realistic way for an attacker to cross a
|
|
27
|
+
security boundary in a supported version of EmailEngine. Unexpected behavior, a
|
|
28
|
+
failing test, or a technically correct proof of concept is not sufficient on its
|
|
29
|
+
own to establish security impact.
|
|
30
|
+
|
|
31
|
+
In particular, explain:
|
|
32
|
+
|
|
33
|
+
- **Attacker capabilities:** Who is the attacker, and what inputs, systems, or
|
|
34
|
+
responses can they control _without_ already having the privileges or secrets
|
|
35
|
+
they are trying to gain?
|
|
36
|
+
- **Attack path:** How does attacker-controlled input reach the affected code
|
|
37
|
+
through a supported EmailEngine interface, such as the REST API, the admin web
|
|
38
|
+
UI, the hosted authentication forms, the built-in SMTP server or IMAP proxy,
|
|
39
|
+
webhook delivery, or an email message that EmailEngine processes?
|
|
40
|
+
- **Prerequisites:** What configuration and user actions are required? If the
|
|
41
|
+
attack depends on unusual options or deliberately malformed input, explain why
|
|
42
|
+
those conditions could arise in a real application.
|
|
43
|
+
- **Impact:** What confidentiality, integrity, or availability boundary is
|
|
44
|
+
crossed, and what can the attacker achieve as a result?
|
|
45
|
+
|
|
46
|
+
A vulnerability involving an optional or less common feature can still qualify
|
|
47
|
+
if these conditions are met. Conversely, the existence of a defensive check in
|
|
48
|
+
the code does not, by itself, establish that every bypass of that check has a
|
|
49
|
+
realistic security impact.
|
|
50
|
+
|
|
22
51
|
## Reporting a Vulnerability
|
|
23
52
|
|
|
24
|
-
**
|
|
25
|
-
pull requests, or discussions
|
|
53
|
+
**Do not disclose suspected exploitable vulnerabilities through public GitHub
|
|
54
|
+
issues, pull requests, or discussions before coordinating with the
|
|
55
|
+
maintainers.**
|
|
26
56
|
|
|
27
57
|
Report privately through one of the following channels:
|
|
28
58
|
|
|
29
|
-
1. **GitHub Security Advisories (preferred)
|
|
30
|
-
<https://github.com/postalsys/emailengine/security/advisories/new>.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
59
|
+
1. **GitHub Security Advisories (preferred):**
|
|
60
|
+
<https://github.com/postalsys/emailengine/security/advisories/new>.
|
|
61
|
+
2. **Email:** **andris@postalsys.com**, as listed in
|
|
62
|
+
[`SECURITY.txt`](SECURITY.txt). Encrypt sensitive details if possible.
|
|
63
|
+
|
|
64
|
+
### Required Information
|
|
65
|
+
|
|
66
|
+
Please provide enough information to evaluate both the defect and its security
|
|
67
|
+
impact. Reports should include:
|
|
68
|
+
|
|
69
|
+
1. The affected EmailEngine version or commit, Node.js version, deployment
|
|
70
|
+
method (npm, Docker, or prebuilt binary), and relevant configuration.
|
|
71
|
+
2. A concise description of the issue and the affected component (for example
|
|
72
|
+
the REST API, admin web UI, OAuth2 flows, the built-in SMTP server or IMAP
|
|
73
|
+
proxy, webhook delivery, credential encryption, or the export pipeline).
|
|
74
|
+
3. A minimal, tested reproduction, including steps to run it, expected behavior,
|
|
75
|
+
and observed behavior.
|
|
76
|
+
4. A concrete threat model: attacker control, prerequisites, trust boundary, and
|
|
77
|
+
resulting impact. Clearly distinguish what your reproduction proves from what
|
|
78
|
+
you believe might be possible.
|
|
79
|
+
5. An explanation of why the issue affects real deployments beyond a
|
|
80
|
+
deliberately constructed test setup, where this is not obvious.
|
|
81
|
+
|
|
82
|
+
A suggested fix is welcome but does not replace an explanation of
|
|
83
|
+
exploitability. A complete real-world exploit is not always necessary, but the
|
|
84
|
+
report must make a credible security impact clear.
|
|
85
|
+
|
|
86
|
+
### Reports That May Be Treated as Ordinary Bugs
|
|
87
|
+
|
|
88
|
+
The following generally do **not** qualify for private security handling unless
|
|
89
|
+
you can demonstrate an additional, meaningful security boundary crossing:
|
|
90
|
+
|
|
91
|
+
- Issues that require the attacker to control trusted application code,
|
|
92
|
+
administrator-only configuration, or the secret they supposedly extract.
|
|
93
|
+
- Problems caused solely by application-level misuse, exposed credentials, or
|
|
94
|
+
insecure deployment choices outside EmailEngine's control.
|
|
95
|
+
- Contrived proof-of-concept setups where the tester controls both sides of a
|
|
96
|
+
request, without explaining how a separate attacker could trigger the issue.
|
|
97
|
+
- Parser quirks, unexpected behavior, and bypasses of internal checks with no
|
|
98
|
+
demonstrated security impact.
|
|
99
|
+
- Speculative findings based only on static analysis or an automated tool's
|
|
100
|
+
assessment, without a verified reproduction and credible attack scenario.
|
|
101
|
+
|
|
102
|
+
These may still be valid bugs and may be considered through the normal issue
|
|
103
|
+
tracker. Please coordinate before making any potentially exploitable details
|
|
104
|
+
public. Classification as a bug does not guarantee a fix or a particular
|
|
105
|
+
priority.
|
|
106
|
+
|
|
107
|
+
### Automated and AI-Assisted Reports
|
|
108
|
+
|
|
109
|
+
Automated analysis and AI tools are welcome as research aids, but the person
|
|
110
|
+
submitting a report is responsible for verifying its claims. **Do not submit
|
|
111
|
+
bulk, unverified, or speculative AI-generated findings.** Test each finding
|
|
112
|
+
against a supported release and establish the actual security impact. Reports
|
|
113
|
+
that do not meet the requirements above may be closed without further
|
|
114
|
+
investigation or individual feedback; they can be resubmitted with stronger
|
|
115
|
+
evidence.
|
|
116
|
+
|
|
117
|
+
## Triage and Disclosure
|
|
118
|
+
|
|
119
|
+
EmailEngine is maintained by a small team, and there is **no guaranteed response
|
|
120
|
+
or resolution time**. Reports are prioritized based on demonstrated impact,
|
|
121
|
+
exploitability, affected usage, and available maintenance resources.
|
|
122
|
+
|
|
123
|
+
A private report does not automatically become a security advisory. Confirmed
|
|
124
|
+
vulnerabilities may be fixed and disclosed through GitHub Security Advisories;
|
|
125
|
+
other findings may be closed, deferred, or handled as ordinary bugs. Please do
|
|
126
|
+
not disclose details of an unresolved, potentially exploitable issue publicly
|
|
127
|
+
without coordinating with the maintainers.
|
|
128
|
+
|
|
129
|
+
## CVEs and Credit
|
|
130
|
+
|
|
131
|
+
We do not request or manage CVE identifiers. A report being acknowledged, a bug
|
|
132
|
+
being fixed, or a pull request being merged does **not** mean that EmailEngine
|
|
133
|
+
has confirmed a security vulnerability or endorsed a CVE assignment. We do not
|
|
134
|
+
guarantee advisories, CVE identifiers, or public credit for reports. For
|
|
135
|
+
confirmed vulnerabilities disclosed through an advisory, substantive reporters
|
|
136
|
+
may be credited if they wish.
|
|
58
137
|
|
|
59
138
|
## Scope
|
|
60
139
|
|
|
61
|
-
In scope: the EmailEngine application source in this repository
|
|
140
|
+
In scope: the EmailEngine application source in this repository: the REST API
|
|
62
141
|
and admin web UI (authentication, session and token handling, CSRF protection),
|
|
63
|
-
OAuth2 application handling, credential encryption at rest, the
|
|
64
|
-
IMAP proxy
|
|
142
|
+
OAuth2 application handling, credential encryption at rest, the built-in SMTP
|
|
143
|
+
server and IMAP proxy, webhook delivery (including custom filter and transform
|
|
65
144
|
functions), the export pipeline, and inter-worker communication.
|
|
66
145
|
|
|
67
146
|
Out of scope:
|
|
68
147
|
|
|
69
148
|
- Vulnerabilities in your own application code that integrates with EmailEngine.
|
|
70
|
-
- Misconfiguration of your deployment
|
|
71
|
-
|
|
72
|
-
|
|
149
|
+
- Misconfiguration of your deployment, for example exposing the admin interface
|
|
150
|
+
or REST API to untrusted networks, weak service secrets, an unauthenticated or
|
|
151
|
+
publicly reachable Redis instance, or missing TLS.
|
|
73
152
|
- Issues that require an already-compromised host or pre-existing administrator
|
|
74
153
|
access.
|
|
75
154
|
- Vulnerabilities in third-party email providers and services that EmailEngine
|
|
76
155
|
connects to (Gmail, Microsoft 365, arbitrary IMAP/SMTP servers).
|
|
77
|
-
-
|
|
78
|
-
|
|
156
|
+
- Missing security headers without a demonstrated, concrete impact.
|
|
157
|
+
- Social-engineering reports.
|
|
79
158
|
|
|
80
159
|
Thank you for helping keep EmailEngine and its users safe.
|
|
@@ -13,6 +13,15 @@ const { MCP_MAX_PAGE_SIZE } = require('../consts');
|
|
|
13
13
|
async function init(args) {
|
|
14
14
|
const { server, CORS_CONFIG } = args;
|
|
15
15
|
|
|
16
|
+
// The queue ID of a message, as every per-message outbox route takes it
|
|
17
|
+
const outboxEntryParams = Joi.object({
|
|
18
|
+
queueId: Joi.string().max(100).example('d41f0423195f271f').description('Queue identifier for scheduled email').required()
|
|
19
|
+
}).label('OutboxEntryParams');
|
|
20
|
+
|
|
21
|
+
// What every per-message route answers for an unknown queue ID. The state refusals the
|
|
22
|
+
// outbox module throws (code NotFailed, ContentGone, NotDelayed) carry a 409 of their own
|
|
23
|
+
const notFound = () => Boom.boomify(new Error('Requested queue entry was not found'), { statusCode: 404 });
|
|
24
|
+
|
|
16
25
|
server.route({
|
|
17
26
|
method: 'GET',
|
|
18
27
|
path: '/v1/outbox',
|
|
@@ -98,9 +107,7 @@ async function init(args) {
|
|
|
98
107
|
try {
|
|
99
108
|
let outboxEntry = await outbox.get({ queueId: request.params.queueId, logger });
|
|
100
109
|
if (!outboxEntry) {
|
|
101
|
-
|
|
102
|
-
let error = Boom.boomify(new Error(message), { statusCode: 404 });
|
|
103
|
-
throw error;
|
|
110
|
+
throw notFound();
|
|
104
111
|
}
|
|
105
112
|
return maskSecrets(outboxEntry);
|
|
106
113
|
} catch (err) {
|
|
@@ -133,9 +140,7 @@ async function init(args) {
|
|
|
133
140
|
},
|
|
134
141
|
failAction,
|
|
135
142
|
|
|
136
|
-
params:
|
|
137
|
-
queueId: Joi.string().max(100).example('d41f0423195f271f').description('Queue identifier for scheduled email').required()
|
|
138
|
-
}).label('OutboxEntryParams')
|
|
143
|
+
params: outboxEntryParams
|
|
139
144
|
},
|
|
140
145
|
|
|
141
146
|
response: {
|
|
@@ -145,6 +150,126 @@ async function init(args) {
|
|
|
145
150
|
}
|
|
146
151
|
});
|
|
147
152
|
|
|
153
|
+
server.route({
|
|
154
|
+
method: 'POST',
|
|
155
|
+
path: '/v1/outbox/{queueId}/retry',
|
|
156
|
+
|
|
157
|
+
async handler(request) {
|
|
158
|
+
try {
|
|
159
|
+
let result = await outbox.retry({ queueId: request.params.queueId, logger });
|
|
160
|
+
if (!result) {
|
|
161
|
+
throw notFound();
|
|
162
|
+
}
|
|
163
|
+
return result;
|
|
164
|
+
} catch (err) {
|
|
165
|
+
handleError(request, err);
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
options: {
|
|
169
|
+
description: 'Retry a failed message',
|
|
170
|
+
notes: 'Puts a message whose delivery failed for good back into the queue with a fresh set of delivery attempts. Only a failed message whose content is still stored can be retried: the content of the most recent failures is kept for this, within the bounds set by EENGINE_QUEUE_KEEP_FAILED_CONTENT and EENGINE_QUEUE_KEEP_FAILED_CONTENT_SIZE. A message that cannot be retried answers 409 with `code` NotFailed (the message is not in the failed state) or ContentGone (its content is no longer stored).',
|
|
171
|
+
tags: ['api', 'Outbox'],
|
|
172
|
+
|
|
173
|
+
plugins: {
|
|
174
|
+
mcp: {
|
|
175
|
+
name: 'retry_queued_message',
|
|
176
|
+
title: 'Retry failed message',
|
|
177
|
+
description:
|
|
178
|
+
'Retry a message whose delivery failed for good, by the queue id from get_outbox. Only a message in the failed state whose content is still stored can be retried; the error says when it cannot. A retried message starts over with a full set of delivery attempts.'
|
|
179
|
+
},
|
|
180
|
+
openapi: {
|
|
181
|
+
responses: apiResponses('Returns a retry marker. The message is waiting for a delivery attempt again.', 400, 401, 403, 404, 409, 429, 500)
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
|
|
185
|
+
auth: {
|
|
186
|
+
strategy: 'api-token',
|
|
187
|
+
mode: 'required'
|
|
188
|
+
},
|
|
189
|
+
cors: CORS_CONFIG,
|
|
190
|
+
|
|
191
|
+
validate: {
|
|
192
|
+
options: {
|
|
193
|
+
stripUnknown: false,
|
|
194
|
+
abortEarly: false,
|
|
195
|
+
convert: true
|
|
196
|
+
},
|
|
197
|
+
failAction,
|
|
198
|
+
|
|
199
|
+
params: outboxEntryParams
|
|
200
|
+
},
|
|
201
|
+
|
|
202
|
+
response: {
|
|
203
|
+
schema: Joi.object({
|
|
204
|
+
retried: apiBoolean().default(true).description('Was the message put back into the queue'),
|
|
205
|
+
queueId: Joi.string().example('d41f0423195f271f').description('Queue identifier of the message'),
|
|
206
|
+
messageId: Joi.string().allow(null, '').example('<test123@example.com>').description('Message-ID header value')
|
|
207
|
+
}).label('RetryOutboxEntryResponse'),
|
|
208
|
+
failAction: 'log'
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
server.route({
|
|
214
|
+
method: 'POST',
|
|
215
|
+
path: '/v1/outbox/{queueId}/promote',
|
|
216
|
+
|
|
217
|
+
async handler(request) {
|
|
218
|
+
try {
|
|
219
|
+
let result = await outbox.promote({ queueId: request.params.queueId, logger });
|
|
220
|
+
if (!result) {
|
|
221
|
+
throw notFound();
|
|
222
|
+
}
|
|
223
|
+
return result;
|
|
224
|
+
} catch (err) {
|
|
225
|
+
handleError(request, err);
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
options: {
|
|
229
|
+
description: 'Send a queued message now',
|
|
230
|
+
notes: 'Moves a message out of the delayed set so it is delivered at the next opportunity instead of at its scheduled time, or instead of after the backoff before its next attempt. Any other state answers 409 with `code` NotDelayed.',
|
|
231
|
+
tags: ['api', 'Outbox'],
|
|
232
|
+
|
|
233
|
+
plugins: {
|
|
234
|
+
mcp: {
|
|
235
|
+
name: 'send_queued_message_now',
|
|
236
|
+
title: 'Send queued message now',
|
|
237
|
+
description:
|
|
238
|
+
'Deliver a queued message at the next opportunity instead of waiting for its scheduled time or for the backoff before its next attempt, by the queue id from get_outbox. Only a message in the delayed state can be promoted.'
|
|
239
|
+
},
|
|
240
|
+
openapi: {
|
|
241
|
+
responses: apiResponses('Returns a promotion marker. The message is waiting for a delivery attempt.', 400, 401, 403, 404, 409, 429, 500)
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
|
|
245
|
+
auth: {
|
|
246
|
+
strategy: 'api-token',
|
|
247
|
+
mode: 'required'
|
|
248
|
+
},
|
|
249
|
+
cors: CORS_CONFIG,
|
|
250
|
+
|
|
251
|
+
validate: {
|
|
252
|
+
options: {
|
|
253
|
+
stripUnknown: false,
|
|
254
|
+
abortEarly: false,
|
|
255
|
+
convert: true
|
|
256
|
+
},
|
|
257
|
+
failAction,
|
|
258
|
+
|
|
259
|
+
params: outboxEntryParams
|
|
260
|
+
},
|
|
261
|
+
|
|
262
|
+
response: {
|
|
263
|
+
schema: Joi.object({
|
|
264
|
+
promoted: apiBoolean().default(true).description('Was the message moved out of the delayed set'),
|
|
265
|
+
queueId: Joi.string().example('d41f0423195f271f').description('Queue identifier of the message'),
|
|
266
|
+
messageId: Joi.string().allow(null, '').example('<test123@example.com>').description('Message-ID header value')
|
|
267
|
+
}).label('PromoteOutboxEntryResponse'),
|
|
268
|
+
failAction: 'log'
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
|
|
148
273
|
server.route({
|
|
149
274
|
method: 'DELETE',
|
|
150
275
|
path: '/v1/outbox/{queueId}',
|
|
@@ -188,9 +313,7 @@ async function init(args) {
|
|
|
188
313
|
},
|
|
189
314
|
failAction,
|
|
190
315
|
|
|
191
|
-
params:
|
|
192
|
-
queueId: Joi.string().max(100).example('d41f0423195f271f').description('Queue identifier for scheduled email').required()
|
|
193
|
-
}).label('OutboxEntryParams')
|
|
316
|
+
params: outboxEntryParams
|
|
194
317
|
},
|
|
195
318
|
|
|
196
319
|
response: {
|
|
@@ -255,6 +255,10 @@ const SURFACE_GRANTS = {
|
|
|
255
255
|
{ action: ACTION.WRITE, group: GROUP.TEMPLATE },
|
|
256
256
|
{ action: ACTION.DESTRUCTIVE, group: GROUP.TEMPLATE },
|
|
257
257
|
{ action: ACTION.READ, group: GROUP.OUTBOX },
|
|
258
|
+
// Retrying a failed message and sending a scheduled one now: operating the queue, which is
|
|
259
|
+
// why they sit here with the cancel and not in the mail table - the mail table is pinned
|
|
260
|
+
// so no issued mail token widens, and a mail agent resubmits instead
|
|
261
|
+
{ action: ACTION.WRITE, group: GROUP.OUTBOX },
|
|
258
262
|
{ action: ACTION.DESTRUCTIVE, group: GROUP.OUTBOX },
|
|
259
263
|
{ action: ACTION.READ, group: GROUP.DIAGNOSTICS },
|
|
260
264
|
{ action: ACTION.READ, group: GROUP.LOGS }
|
|
@@ -459,7 +463,13 @@ const GROUP_ROUTES = {
|
|
|
459
463
|
'POST /v1/delivery-test/account/{account}'
|
|
460
464
|
],
|
|
461
465
|
|
|
462
|
-
[GROUP.OUTBOX]: [
|
|
466
|
+
[GROUP.OUTBOX]: [
|
|
467
|
+
'GET /v1/outbox',
|
|
468
|
+
'GET /v1/outbox/{queueId}',
|
|
469
|
+
'POST /v1/outbox/{queueId}/retry',
|
|
470
|
+
'POST /v1/outbox/{queueId}/promote',
|
|
471
|
+
'DELETE /v1/outbox/{queueId}'
|
|
472
|
+
],
|
|
463
473
|
|
|
464
474
|
[GROUP.EXPORT]: [
|
|
465
475
|
'POST /v1/account/{account}/export',
|
package/lib/consts.js
CHANGED
|
@@ -314,10 +314,6 @@ module.exports = {
|
|
|
314
314
|
|
|
315
315
|
NONCE_BYTES: 16,
|
|
316
316
|
|
|
317
|
-
// Where the bull-board queue browser is mounted (lib/api-routes/bull-board-routes.js); the
|
|
318
|
-
// security headers key their bull-board profile on it
|
|
319
|
-
BULL_BOARD_BASE_PATH: '/admin/bull-board',
|
|
320
|
-
|
|
321
317
|
// Longest account id EmailEngine accepts. Defined here rather than only on `accountIdSchema`
|
|
322
318
|
// because the token audit log truncates to it while writing, before route validation has had a
|
|
323
319
|
// chance to reject a longer one, and the two have to agree: a log that trimmed at a different
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* How often an IMAP connection restarts IDLE (ImapFlow's `maxIdleTime`) and which command keeps it
|
|
5
|
+
* alive on a server without IDLE (`missingIdleCommand`).
|
|
6
|
+
*
|
|
7
|
+
* A few providers get a built-in value, and an account can set its own `imap.maxIdleTime` for a
|
|
8
|
+
* server, or something in front of it, that drops a connection left idle for a few minutes without
|
|
9
|
+
* sending BYE. The account value wins over the built-in one.
|
|
10
|
+
*
|
|
11
|
+
* Kept free of connection and Redis code so the rules can be tested on their own.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const PROVIDER_IDLE_SETTINGS = [
|
|
15
|
+
// Rambler supports IDLE but needs it restarted frequently
|
|
16
|
+
{ host: /\.rambler\.ru$/i, maxIdleTime: 55 * 1000 },
|
|
17
|
+
// 163.com (Coremail) does not support IDLE and ignores NOOP for idle timer reset.
|
|
18
|
+
// Use STATUS as the keepalive command - it counts as real activity for the server.
|
|
19
|
+
{ host: /\.163\.com$/i, maxIdleTime: 55 * 1000, missingIdleCommand: 'STATUS' },
|
|
20
|
+
// Break IDLE at least once every three minutes
|
|
21
|
+
{ host: /\.yahoo\.com$/i, maxIdleTime: 3 * 60 * 1000 }
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Sets the IDLE options on a connection config that is about to be handed to ImapFlow
|
|
26
|
+
* @param {Object} imapConfig - The ImapFlow config, modified in place
|
|
27
|
+
* @param {Object} [accountImap] - The account's stored `imap` object. Read on its own because an
|
|
28
|
+
* OAuth2 account builds its connection config without it
|
|
29
|
+
*/
|
|
30
|
+
function applyIdleSettings(imapConfig, accountImap) {
|
|
31
|
+
const provider = PROVIDER_IDLE_SETTINGS.find(entry => entry.host.test(imapConfig.host || ''));
|
|
32
|
+
if (provider) {
|
|
33
|
+
imapConfig.maxIdleTime = provider.maxIdleTime;
|
|
34
|
+
if (provider.missingIdleCommand) {
|
|
35
|
+
imapConfig.missingIdleCommand = provider.missingIdleCommand;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (accountImap?.maxIdleTime) {
|
|
40
|
+
imapConfig.maxIdleTime = accountImap.maxIdleTime;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
module.exports = { applyIdleSettings };
|
|
@@ -1277,6 +1277,8 @@ class Mailbox {
|
|
|
1277
1277
|
let bounceNotifyInfo;
|
|
1278
1278
|
let complaintNotifyInfo;
|
|
1279
1279
|
let content;
|
|
1280
|
+
// Set once a download found the message already expunged
|
|
1281
|
+
let messageGone = false;
|
|
1280
1282
|
|
|
1281
1283
|
// Check if this might be an ARF (Abuse Reporting Format) complaint
|
|
1282
1284
|
if (this.connection.mightBeAComplaint(messageInfo)) {
|
|
@@ -1336,19 +1338,29 @@ class Mailbox {
|
|
|
1336
1338
|
|
|
1337
1339
|
// Check if this might be a DSN (Delivery Status Notification)
|
|
1338
1340
|
if (this.connection.mightBeDSNResponse(messageInfo)) {
|
|
1341
|
+
let sourceStream;
|
|
1339
1342
|
try {
|
|
1340
|
-
|
|
1343
|
+
({ content: sourceStream } = await this.requireImapClient().download(messageInfo.uid, false, {
|
|
1341
1344
|
uid: true,
|
|
1342
1345
|
chunkSize: options.chunkSize,
|
|
1343
1346
|
maxBytes: MAX_ALLOWED_DOWNLOAD_SIZE
|
|
1344
|
-
});
|
|
1347
|
+
}));
|
|
1345
1348
|
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1349
|
+
// No content means the message was expunged after it was detected (a server-side
|
|
1350
|
+
// filter moving it to Junk, for instance), which is a normal race and not a failure.
|
|
1351
|
+
// The bounce check below does not ask for it again
|
|
1352
|
+
if (!sourceStream) {
|
|
1353
|
+
messageGone = true;
|
|
1354
|
+
} else {
|
|
1355
|
+
let parsed = await parseMessage(sourceStream, DSN_PARSER_OPTIONS);
|
|
1356
|
+
if (parsed) {
|
|
1357
|
+
content = { parsed };
|
|
1358
|
+
applyDeliveryReport(parsed, messageInfo, this.logger);
|
|
1359
|
+
}
|
|
1350
1360
|
}
|
|
1351
1361
|
} catch (err) {
|
|
1362
|
+
// A parser failure leaves the IMAP download unconsumed
|
|
1363
|
+
sourceStream?.destroy?.();
|
|
1352
1364
|
if (isConnectionGone(err)) {
|
|
1353
1365
|
throw err;
|
|
1354
1366
|
}
|
|
@@ -1366,7 +1378,7 @@ class Mailbox {
|
|
|
1366
1378
|
if (this.connection.mightBeABounce(messageInfo)) {
|
|
1367
1379
|
// Parse for bounce information
|
|
1368
1380
|
try {
|
|
1369
|
-
if (!content) {
|
|
1381
|
+
if (!content && !messageGone) {
|
|
1370
1382
|
let result = await this.requireImapClient().download(messageInfo.uid, false, {
|
|
1371
1383
|
uid: true,
|
|
1372
1384
|
chunkSize: options.chunkSize,
|
|
@@ -20,6 +20,7 @@ const { connectionNotAvailableError, connectionUnavailableError } = require('./i
|
|
|
20
20
|
const { ReconnectBackoff } = require('./reconnect-backoff');
|
|
21
21
|
const { isRefusedImapLogin, imapResponseText } = require('./imap/login-failure');
|
|
22
22
|
const { knownUidNext, planStaleViewProbe, evaluateStaleViewProbe } = require('./imap/stale-view');
|
|
23
|
+
const { applyIdleSettings } = require('./imap/idle-settings');
|
|
23
24
|
|
|
24
25
|
const {
|
|
25
26
|
normalizePath,
|
|
@@ -1692,27 +1693,8 @@ class IMAPClient extends BaseClient {
|
|
|
1692
1693
|
}
|
|
1693
1694
|
}
|
|
1694
1695
|
|
|
1695
|
-
// Provider
|
|
1696
|
-
|
|
1697
|
-
// Rambler supports IDLE but needs it restarted frequently
|
|
1698
|
-
imapConfig.maxIdleTime = 55 * 1000;
|
|
1699
|
-
} else if (/\.163\.com$/i.test(imapConfig.host)) {
|
|
1700
|
-
// 163.com (Coremail) does not support IDLE and ignores NOOP for idle timer reset.
|
|
1701
|
-
// Use STATUS as the keepalive command - it counts as real activity for the server.
|
|
1702
|
-
imapConfig.maxIdleTime = 55 * 1000;
|
|
1703
|
-
imapConfig.missingIdleCommand = 'STATUS';
|
|
1704
|
-
} else if (/\.yahoo\.com$/i.test(imapConfig.host)) {
|
|
1705
|
-
// Special case for Yahoo. Break IDLE at least once every three minutes
|
|
1706
|
-
imapConfig.maxIdleTime = 3 * 60 * 1000;
|
|
1707
|
-
}
|
|
1708
|
-
|
|
1709
|
-
/*
|
|
1710
|
-
else if (/(\.naver\.com)$/i.test(imapConfig.host)) {
|
|
1711
|
-
// NOOP does nothing in Naver, must run SELECT for changes in the folder to apply
|
|
1712
|
-
imapConfig.maxIdleTime = 55 * 1000;
|
|
1713
|
-
imapConfig.missingIdleCommand = 'SELECT';
|
|
1714
|
-
}
|
|
1715
|
-
*/
|
|
1696
|
+
// Provider IDLE workarounds, and the account's own IDLE restart interval
|
|
1697
|
+
applyIdleSettings(imapConfig, accountData.imap);
|
|
1716
1698
|
|
|
1717
1699
|
// Apply global settings
|
|
1718
1700
|
if (DISABLE_IMAP_COMPRESSION) {
|
package/lib/enum-descriptions.js
CHANGED
|
@@ -44,6 +44,13 @@ const ENUM_DESCRIPTIONS = {
|
|
|
44
44
|
error: 'Delivery failed. See the error field for the reason and whether it will be retried'
|
|
45
45
|
},
|
|
46
46
|
|
|
47
|
+
outboxState: {
|
|
48
|
+
delayed: 'Waiting for its scheduled time, or for the backoff before its next delivery attempt',
|
|
49
|
+
waiting: 'Ready to be delivered as soon as a submit worker is free',
|
|
50
|
+
active: 'A delivery attempt is running right now',
|
|
51
|
+
failed: 'Every delivery attempt failed, or the receiving server rejected the message for good. Listed while the job record is retained, and retryable while its content is'
|
|
52
|
+
},
|
|
53
|
+
|
|
47
54
|
outboxSource: {
|
|
48
55
|
smtp: 'Submitted through the built-in SMTP server',
|
|
49
56
|
api: 'Submitted through the REST API',
|
package/lib/export.js
CHANGED
|
@@ -7,6 +7,7 @@ const pathlib = require('path');
|
|
|
7
7
|
const zlib = require('zlib');
|
|
8
8
|
const { pipeline } = require('stream');
|
|
9
9
|
const msgpack = require('./msgpack');
|
|
10
|
+
const { statusError } = require('./utils/status-error');
|
|
10
11
|
const { redis, exportQueue } = require('./db');
|
|
11
12
|
const settings = require('./settings');
|
|
12
13
|
const logger = require('./logger');
|
|
@@ -208,12 +209,7 @@ function generateExportId() {
|
|
|
208
209
|
return EXPORT_ID_PREFIX + crypto.randomBytes(12).toString('hex');
|
|
209
210
|
}
|
|
210
211
|
|
|
211
|
-
|
|
212
|
-
const err = new Error(message);
|
|
213
|
-
err.code = code;
|
|
214
|
-
err.statusCode = statusCode;
|
|
215
|
-
return err;
|
|
216
|
-
}
|
|
212
|
+
const createError = statusError;
|
|
217
213
|
|
|
218
214
|
// Error classifiers used by the export worker to decide between retrying, skipping a single
|
|
219
215
|
// message, or failing the whole export job.
|