Merge claude/postgres-mail-deadlock: Postgres keeps connections free of transactions; form and account mail go out after the commit
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
+20
-4
@@ -455,6 +455,12 @@ and password switches the site to the client's server.
|
||||
- Missing SMTP config or a send error → the adapter **does not throw**, it returns `{ sent: false, error }` and logs.
|
||||
- Port 465 → implicit TLS, others → STARTTLS.
|
||||
- The adapter reads the config on every send, so changing the mailbox in the panel works without a restart.
|
||||
- **Time-outs** (since 1.17.0): 10 s to connect, 30 s for the server's greeting, 60 s of silence during the
|
||||
dialogue (`SMTP_TIMEOUT_DEFAULTS`; nodemailer's own were 2 min and 10 min). A send inside a database transaction —
|
||||
Payload's "forgot password" with `mail: { accountMailAfterCommit: false }` — holds a connection that long
|
||||
([deployment.md](./deployment.md) §4.3a; by default that mail goes out after its transaction commits). Change them:
|
||||
`mailAdapter({ smtp: { timeouts: { connectionMs, greetingMs, socketMs } } })` or `panelSmtpAdapter({ timeouts })`
|
||||
(type `SmtpTimeouts`).
|
||||
|
||||
SMTP only, without the dispatcher:
|
||||
|
||||
@@ -470,7 +476,8 @@ export default buildConfig({
|
||||
})
|
||||
```
|
||||
|
||||
Options: `fallbackFromAddress` (`'noreply@localhost'`), `fallbackFromName` (`'Website'`).
|
||||
Options: `fallbackFromAddress` (`'noreply@localhost'`), `fallbackFromName` (`'Website'`), `timeouts`
|
||||
(`{ connectionMs: 10000, greetingMs: 30000, socketMs: 60000 }`).
|
||||
|
||||
## Dependency
|
||||
|
||||
@@ -520,7 +527,14 @@ if (result.sent) {
|
||||
|
||||
Password reset and e-mail verification go through Payload's built-in mechanism (`config.email`). With
|
||||
`mailAdapter()` wired they take the same transport as everything else; with the mail service they are sent as
|
||||
account mail ("What a message is").
|
||||
account mail ("What a message is"). Payload sends them inside the operation's database transaction; `mailAdapter()`
|
||||
sends them right **after** it commits instead (still in the same request; nothing when it is rolled back), so a slow
|
||||
mail server holds no database connection — `mail: { accountMailAfterCommit: false }` keeps them inside
|
||||
([deployment.md](./deployment.md) §4.3a). The message is matched to its request by the token it carries (and the
|
||||
account's address), never by the address alone: a form's mail to the same address goes out as usual. A project's own
|
||||
`forgotPassword.generateEmailSubject` / `verify.generateEmailSubject` is kept; an own `generateEmailHTML` must put the
|
||||
token in the body (any working reset link does), or that mail is sent inside the transaction as before. An e-mail adapter of your own does the same by calling
|
||||
`sendAccountMailAfterCommit(message, () => send(message))` first.
|
||||
|
||||
## Masking secrets in the panel (MaskedField)
|
||||
|
||||
@@ -717,7 +731,8 @@ Save your changes before the test — the endpoint reads from the database, not
|
||||
## Send status in the panel
|
||||
|
||||
`mailAdapter()` stores the send result in Site integrations (at most once per 10 min
|
||||
while an error persists, immediately when the state changes). When sending fails:
|
||||
while an error persists, immediately when the state changes; many sends failing at once write it once, and while a
|
||||
Postgres pool is busy the write goes on in the background — [integrations.md](./integrations.md)). When sending fails:
|
||||
- **Dashboard** — a red alert with the cause and a link to Site integrations,
|
||||
- **Site integrations → E-mail sending** — a banner with the error (e.g. `SMTP: connect ECONNREFUSED …`,
|
||||
`SMTP: Invalid login: 535 …`, `Microsoft Graph: Graph sendMail failed (403).`, or the text of a mail service
|
||||
@@ -756,7 +771,8 @@ SDK); you then skip the panel's SMTP fields, the mail service and the send statu
|
||||
integrations and the endpoint `POST /api/ipal/test-email` are always added.
|
||||
- **Choosing the transport:** `mailAdapter()` (decided per send) or a fixed `relayAdapter()` /
|
||||
`panelSmtpAdapter()` / `graphAdapter()`; any other Payload adapter also works.
|
||||
- **Override:** `fallbackFromAddress` / `fallbackFromName`; in `mailAdapter` separately `relay`, `smtp` and `graph`
|
||||
- **Override:** `fallbackFromAddress` / `fallbackFromName`; in `mailAdapter` separately `relay`, `smtp` (with
|
||||
`smtp.timeouts`) and `graph`
|
||||
(`graph.largeAttachments: false` keeps Graph to attachments under 3 MB — "Attachments"); every option of the
|
||||
mail service ("Options"); panel texts through `i18n.translations` (keys `mailRelay…`, `statusEmailRelay…`);
|
||||
the tab's fields through `integrationsFields`.
|
||||
|
||||
Reference in New Issue
Block a user