Add disclaimer via sieve overrides e-mail content

Your question

Hi there!

I am trying to add a disclaimer to every outgoing E-Mails as described in the stalwart docs at Body & Attachments | Stalwart

I added the sieve script under Settings: Sieve: System Scripts with “disclaimer” as name and activated it.

Afterwards under Settings: MTA: Session: DATA Stage: Run Script: ELSE: I added ‘disclaimer’.

After a restart of stalwart now all outgoing E-Mails contain the disclaimer as desired, but the content of the E-Mail is gone.

I am sending plaintext E-Mails with Thunderbird from a stalwart account to an external address.

stalwart version is v0.16.8 deployed on Debian 13 via the official installer and rocksdb storage.

Thanks in advance!

I understand that topics in this category are triaged by a bot first but a human reply will follow up. If I’d prefer a human-only reply, I’ll add the no-ai tag to my topic.

on

This is a problem with the example in the docs, not your setup. That extracttext “body” followed by replace “${body}${disclaimer}” only works inside a foreverypart loop: at the top level extracttext produces an empty variable, so replace ends up overwriting the whole body with just the disclaimer, which is exactly what you saw.

Wrap it so it operates on the current text part, for example:

foreverypart {
  if header :mime :param "filename" :matches "Content-Disposition" "*" { stop; }
  if header :mime :contains "Content-Type" "text/plain" {
    extracttext :upper "body";
    replace "${body}${disclaimer}";
  }
}

Or use the enclose action, which wraps the original message and adds the disclaimer as a separate part.

Thanks for your reply. Good to hear there is a solution.

Could you update the docs with a working example, please? Thanks in advance!

Bought a 25 mailbox enterprise license for now and testing stalwart as an exchange replacement for around 600 users at the moment. Looks promising so far! Thanks for your work!