Hi,
Right now, at the DATA stage an MTA Hook always gets the whole message in message.contents: headers, body and every attachment. As far as I can tell there’s no setting to send less. The hook options are url, stages, enable, timeout, httpAuth, httpHeaders, tempFailOnError, maxResponseSize and allowInvalidCerts.
My use case: I run a small service that downloads the remote images of each incoming email as it arrives, so the sender can’t tell when (or if) the email is opened, similar to what Proton does. The service only needs the HTML parts, not attachments or the rest of the message. Today the only way to avoid sending every incoming email in full to that service is a small program on the mail server that receives the hook, strips the message down and forwards only what’s needed. It works, but it’s an extra moving part on the mail server, just to work around this.
Being able to limit what the hook sends would help for:
- Privacy: the hook endpoint only gets the data it actually needs, not every attachment of every email.
- Efficiency: no need to send several MB of attachments per message to a service that ignores them.
- Less exposure: if the external service is compromised, less mail data is exposed.
A few possible ways to do it, whichever fits Stalwart best:
- A content setting on the hook, for example: headers only / headers + body without attachments / full message (as today).
- Only send MIME parts of the listed content types (e.g.
text/html,text/plain). - A maximum size for
contents, with larger parts left out.
The current behaviour should stay the default, so existing hooks keep working.
Happy to test it if there’s a preview build.
Thanks!