---
title: "Apple Mail — 'Trust junk mail headers' Silent Auto-Deletion"
aliases: [apple-mail-junk-headers, apple-mail-x-spam, apple-mail-auto-delete, trust-junk-headers]
tags: [apple-mail, email, spam, rspamd, junk, macos]
sources:
  - "daily/2026-05-08.md"
created: 2026-05-08
updated: 2026-05-08
---

# Apple Mail — "Trust junk mail headers" Silent Auto-Deletion

Apple Mail has a setting — **Mail → Settings → Junk Mail → "Trust junk mail headers in messages"** — that causes it to read `X-Spam-*` headers set by server-side spam filters (rspamd, SpamAssassin) and silently move or delete messages without showing them in the inbox. Combined with an IMAP agent that expunges deleted messages, this results in permanent email loss.

## Key Points

- When enabled, Apple Mail reads `X-Spam-Flag: YES` or similar headers and acts on them **before** displaying the message.
- The message goes directly to Junk or Trash — never appearing in the inbox — making the problem invisible.
- If the IMAP account also has a client or agent that expunges deleted/junk items, the message is permanently lost.
- The setting is on by default in many macOS versions.
- Disabling it does **not** recover already-deleted messages (see [[wiki/concepts/dovecot-expunge-irreversible]]).

## The Failure Chain

```
rspamd scores message as spam
    → sets X-Spam-Flag: YES header
    → Apple Mail reads header (Trust junk mail headers = ON)
    → Apple Mail moves message to Junk/Trash silently
    → IMAP agent (e.g. bookkeeper-agent) runs doveadm expunge on Trash
    → message permanently deleted
```

Each step is individually "correct" — the catastrophic outcome requires all three.

## Fix

### Disable "Trust junk mail headers"

1. Open **Mail** → **Settings** (⌘,)
2. Go to the **Junk Mail** tab
3. Uncheck **"Trust junk mail headers in messages"**

Apple Mail will now use its own local Junk filter (or none), ignoring server-set headers.

### Add trusted senders to macOS Contacts

Apple Mail never marks messages from Contacts as junk:

1. Open **Contacts** → create a contact for the sender's email address
2. In Mail Junk settings: ensure **"Sender of message is in my Contacts"** is checked under exceptions

### Audit IMAP agents

Any script or service that runs `doveadm expunge`, `IMAP EXPUNGE`, or moves Junk→Trash automatically should be reviewed and disabled if not explicitly needed.

## Diagnosing the Problem

If emails are missing:

```bash
# Check rspamd scored them as spam
docker logs mailcowdockerized-rspamd-mailcow-1 --since 24h | grep -i "sender@domain"

# Check if messages were expunged
docker exec mailcowdockerized-dovecot-mailcow-1 \
    doveadm log search "expunge" | tail -50
```

In Apple Mail: **View → Show All Headers** on a received message — look for `X-Spam-Flag` or `X-Spam-Score` headers to confirm rspamd is tagging them.

## Related Concepts

- [[wiki/concepts/rspamd-mailcow-whitelist]] — fix the root cause by whitelisting the sender domain in rspamd
- [[wiki/concepts/dovecot-expunge-irreversible]] — why recovery is impossible once expunge runs

## Sources

- [[daily/2026-05-08.md]] — emails from axilaccountants.co.uk disappeared; root cause: rspamd tagged as spam → Apple Mail auto-deleted (trust junk headers ON) → bookkeeper-agent expunged from Trash; emails permanently lost
