> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mailchannels.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Sender identity headers in MailChannels Outbound Filtering

> Learn which message headers MailChannels Outbound Filtering evaluates, in priority order, to determine the responsible sender ID for each email.

When you relay mail through MailChannels Outbound Filtering, we inspect each message's headers to determine the responsible **sender ID**: the specific user, script, mailing list, or external source that originated the message. Accurate sender identification lets MailChannels isolate compromised accounts and contain abusive traffic without disrupting legitimate mail from the rest of your platform.

MailChannels checks message headers in a fixed priority order and uses the first matching source it finds.

## 1. Primary sender identity headers

MailChannels first checks for the following headers in exact priority order. As long as the message has a non-empty SMTP envelope sender (`MAIL FROM`), the first non-blank header present determines the sender ID:

| Priority | Header | What it identifies |
| - | - | - |
| 1 | `X-Cron-Env` | Cron-generated system mail |
| 2 | `X-AuthUser` | Authenticated mail user |
| 3 | `X-Sender-Id` | External or explicitly tagged sender |
| 4 | `X-phpBB-Origin` | Mail sent from a phpBB script |
| 5 | `X-PHP-Originating-Script` | PHP script that generated the message |
| 6 | `Authenticated sender` | Authenticated user |
| 7 | `X-MC-MailingList` | Mailing list |
| 8 | `X-SmarterMail-Authenticated-As` | Authenticated SmarterMail user |
| 9 | `X-PHP-Script` | PHP script that sent the message |
| 10 | `X-Authenticated-User` | Authenticated user |
| 11 | `x-aol-sid` | AOL sender ID |
| 12 | `X-Authenticated-Sender` | Authenticated sender |
| 13 | `X-Declude-Sender` | Declude sender |

### Duplicate headers

If a message contains multiple instances of the same header from the table above, MailChannels handles them as follows:

* **`X-AuthUser`**: MailChannels uses the **bottom-most** (most recently added) header value, which is typically the header inserted by your mail server.
* **All other primary headers**: If every instance of the header has the same value, MailChannels uses that value. If the values differ, MailChannels skips that header to prevent spoofing and continues down the priority list.

## 2. Authenticated sender in `Received` headers

If none of the primary headers above match, MailChannels checks the message's `Received` headers for an authenticated sender string in this format:

```text theme={null}
(Authenticated sender: <username>)
```

When found, MailChannels extracts `<username>` as the sender identity.

## 3. Script origin header (`X-SG-Opt`)

Next, MailChannels checks for the `X-SG-Opt` header, which contains `key=value` pairs inserted by PHP environments. MailChannels uses the `SCRIPT_FILENAME` value (or `USER` if `SCRIPT_FILENAME` is absent), paired with your sending server's IP address.

## 4. Auto-reply headers (`Auto-Submitted`, `X-Autorespond`)

If either `Auto-Submitted` or `X-Autorespond` is present, the SMTP envelope sender is non-empty, and the message is not a mailer-daemon bounce, MailChannels classifies the message as an auto-reply and derives the sender ID from the SMTP envelope sender.

## 5. Interspire headers (`X-Mailer-LID`, `X-Mailer-Sent-By`)

If both `X-Mailer-LID` and `X-Mailer-Sent-By` are present with numeric values, MailChannels combines those values with your sending server's IP address to form the sender ID.

## 6. Fallback headers (`From` and `Received`)

If none of the headers above identify the sender, MailChannels checks two final header fallbacks before falling back to non-header signals:

* **`From`**: Checked for `mailer-daemon@` (alongside an empty SMTP envelope sender `<>`) to identify bounces and mailer-daemon notifications.
* **`Received`**: Scanned from bottom to top (when the message is not an SRS-rewritten forwarded message) to extract an originating SquirrelMail authenticated user, local user ID, authenticated sender, or external sending IP address. Private and customer-owned IP addresses and hostnames are ignored during this scan.

If no header yields a sender identity, MailChannels falls back to the SMTP envelope sender (`MAIL FROM`) or, when no envelope sender is available, a hash of the message recipients.

> [!NOTE]
>
> Because envelope sender addresses are easy to spoof, high-volume mail that falls back to `env-sender` may be rejected with an `[ESR]` policy error. See [SMTP errors](https://docs.mailchannels.com/outbound/smtp-errors.md) for details.

## Best practices

To ensure MailChannels attributes every message to the right sender on your platform:

1. **Insert a dedicated sender header at your MTA.** Configure your mail server to add `X-AuthUser` (or another primary header such as `X-Authenticated-User`) with the authenticated user or account identifier for every outbound message. See [Configure your mail server](https://docs.mailchannels.com/outbound/configure-mail-server.md) for MTA-specific instructions.
2. **Strip untrusted copies from incoming submissions.** Remove any client-supplied copies of `X-AuthUser` or other sender identity headers before your MTA inserts its own trusted value.
3. **Verify your sender IDs.** Send a test message and open **Outbound > Log Search** in the [Host Console](https://console.mailchannels.net) to confirm the sender ID reflects the expected header value. You can inspect per-sender history in [Sender Profiles](https://docs.mailchannels.com/outbound/sender-profiles.md) and restrict authorized senders with [Domain Lockdown](https://docs.mailchannels.com/outbound/domain-lockdown.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.