Skip to content

πŸ› Bug Report: Preview-line whitespace padding in auth emails triggers rspamd HIDDEN_TEXT (+2.5 spam score)Β #14089

Closed

Description

@moritztirom

πŸ‘Ÿ Reproduction steps

  1. On a self-hosted instance with a custom SMTP server for the project, trigger any auth email (password recovery, verification, magic URL, OTP, …).
  2. The mails worker (src/Appwrite/Platform/Workers/Mails.php) pads the preview text up to 150 characters with &#xa0;&#x200C;&#x200B;&#x200D;&#x200E;&#x200F;&#xFEFF; repeated, and inserts it as {{previewWhitespace}} inside the hidden preview <div> in email-base.tpl (and email-base-styled.tpl).
  3. For a typical preview such as "Reset your {{project}} password using the link." that comes to about 100 repeats, so about 700 invisible characters.
  4. Score the delivered message with rspamd (current rspamd/rspamd:latest image, default config).

πŸ‘ Expected behavior

The preview line doesn't add to the spam score, or projects can turn the padding off.

πŸ‘Ž Actual behavior

rspamd fires HIDDEN_TEXT (2.51) plus MANY_INVISIBLE_PARTS. Same message, scored locally, with only the padding changed:

Variant Score HIDDEN_TEXT
Stock email-base.tpl 3.98 2.51
<div>{{previewWhitespace}}</div> removed (hidden preview text kept) 1.42 β€”

The hidden preview <div> on its own isn't penalised; the zero-width run is. Together with other common rules this is enough for some providers' outbound filters to hold the mail. In our case, a German hoster (ALL-INKL) held password-reset mails for 10 minutes (X-Kas-Delay) before delivering them. With the padding line removed from the template (nothing else changed), the same reset mail passed in 3 seconds and the hoster marked it X-Spamd-Bar: /, down from +++++++.

A project can't avoid it: the preview text always comes from the locale (emails.<type>.preview), a custom template only replaces {{body}}, and the padding is added in the worker regardless of smtpBaseTemplate. The only workaround is to mount a patched email-base.tpl into the worker container.

Suggestions, any of which would help:

  • drop the padding, or use a much shorter run (a few &#x200C;&nbsp; pairs is the common practice);
  • leave it out when a custom template message is set;
  • make it configurable (env var or project setting).

🎲 Appwrite version

Self-hosted 2.0.0; the code is unchanged on main (checked 2026-10-04).

πŸ’» Operating system

Linux

🧱 Your Environment

Docker Compose, project-level custom SMTP.

πŸ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏒 Have you read the Code of Conduct?

  • I have read the Code of Conduct

Activity

  1. added
    product / auth
    product / databases
    product / functions
    product / locale
    product / messaging
    product / self-hosted
    product / storage
    on Oct 4, 2026
  2. PRINCE-TIWARI07 commented on Oct 4, 2026

    @PRINCE-TIWARI07

    Hey! I'd love to take this one.

    I had a look at the code and found the cause in Mails.php and Notifications.php. The padding repeats a group of 7 invisible characters (150 minus the preview length) times, so it ends up with roughly 7x more hidden characters than the 150-character limit was meant to allow.

    What I'm thinking: keep the padding but make it match the intended length, using a short β€ŒΒ  pattern in both workers. I'd keep the {{previewWhitespace}} placeholder so custom templates don't break, and add tests. If a shorter run still triggers HIDDEN_TEXT in rspamd, I'd drop the padding entirely instead.

    Does that sound okay to you? Could you assign this to me? Happy to change the approach if you'd prefer something else.

  3. J-4-K-3 commented on Oct 4, 2026

    @J-4-K-3

    Hi! I'd like to investigate and work on this issue

    I've traced the preview padding through both Mails.php and Notifications.php and confirmed that previewWhitespace is intentionally generated and inserted into the shared email templates. I also traced it back to the commit that introduced the mechanism

    I have a minimal candidate approach, but I want to validate the inbox-preview behavior and rspamd impact before proposing a final fix

    I'd be happy to take this issue if it's available

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    product / authproduct / databasesproduct / functionsproduct / localeproduct / messagingproduct / self-hostedproduct / storage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions