Form attachments proposal: Graph upload session recommended (Mail.ReadWrite already granted)

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-11-13 16:04:07 +01:00
co-authored by Claude Fable 5.2
parent 62bed415ed
commit 0ba0014ed5
+17 -7
View File
@@ -146,7 +146,10 @@ a real test instead of trusting them: **Send test e-mail** in the panel gets "wi
unless it is scoped to the one sender mailbox. The draft is sent *from the mailbox*, so a copy passes through
Drafts and lands in Sent Items, and must be deleted afterwards. Microsoft lists a known issue with upload
sessions on shared mailboxes, and `GRAPH_SENDER` is one.
- So the real maximum on Graph **today is under 3 MB**; 10 MB needs either the upload session or SMTP (decision 1).
- The agency's Azure app **already has `Mail.ReadWrite`** (application, admin consent granted — confirmed by the
owner on 2026-11-13, together with `Mail.Read` and `Mail.Send`). So the upload session needs no Azure change.
- So the real maximum on Graph is under 3 MB with the code as it is, and 10 MB once the upload session is built
(decision 1).
**The limit the visitor sees is the limit that works.** The effective maximum is the lowest of: the field's
`maxSizeMB`, the plugin cap `attachments.maxSizeMB`, and the transport's cap (3 MB on Graph without a large-file
@@ -280,11 +283,17 @@ any field. `RenderForm` needs no new prop; a hand-built form on the hook gets th
Recommendation first in each.
1. **Sites that send through Microsoft Graph, files of 3 MB and more.**
**Send those e-mails through the SMTP settings in the panel; without SMTP the limit on Graph is 3 MB**, and
the form and the panel say so. No change to the agency's Azure app.
— *or* build the Graph upload session: 10 MB on Graph, but the agency app needs `Mail.ReadWrite` (scoped to
the forms mailbox), the secret that sits in every project's environment gains mailbox read access, and each file
passes through that mailbox's Drafts and Sent Items before the plugin deletes it.
**Build the Graph upload session**, since the agency app already has `Mail.ReadWrite`: 10 MB works on Graph
with no Azure change. Files under 3 MB keep the inline path. Cost to accept: each larger file passes through
the sender mailbox's Drafts and Sent Items; the plugin deletes the draft on failure and the sent copy after
sending, and a failed clean-up is logged. The build first tests Microsoft's known issue with shared
mailboxes on `GRAPH_SENDER`; if it blocks the upload, the fallback is the alternative below.
— *or* send those e-mails through the SMTP settings in the panel; without SMTP the limit on Graph is 3 MB.
Nothing touches the mailbox, but every Graph site that wants 10 MB needs SMTP set up too.
Separate from this feature, for the agency to consider: the app's permissions cover **all mailboxes** of the
tenant, and its secret sits in every project's environment. Limiting the app to the forms mailbox (an
application access policy in Exchange) would shrink that. Not part of this build.
2. **When the e-mail cannot be sent.**
**The visitor sees an error and can retry; staff get a notice without the file; the submission is marked
"Not sent".** — *or* the visitor sees the normal confirmation and staff must ask again.
@@ -322,4 +331,5 @@ Recommendation first in each.
- A Payload custom endpoint receives the body as an unread stream on Next 16.4.
- Traefik's read timeout in Coolify on a slow 10 MB upload (needs a real deploy).
- The SMTP size limits of the providers our projects use (the large test e-mail measures it).
- On Graph: the exact request size at which inline `sendMail` starts to fail (Microsoft documents "under 3 MB").
- On Graph: the exact request size at which inline `sendMail` starts to fail (Microsoft documents "under 3 MB"),
and whether the upload session works on the shared `GRAPH_SENDER` mailbox.