> ## 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.

# Setup Sendmail

> Configure Sendmail to relay outbound mail through MailChannels Outbound Filtering using SMTP authentication and smart host routing.

This guide walks you through configuring Sendmail to relay all outbound mail through MailChannels Outbound Filtering.

<Note>
  Sendmail requires `libsasl` to send authentication requests to MailChannels servers. The `saslauthd` daemon is not required unless you plan to receive authentication requests on the same server. See the [Sendmail SASL support page](http://www.sendmail.com/sm/open_source/tips/compiling_sendmail/#SASL) for more information.
</Note>

## Prerequisites

* Root or `sudo` access to your Sendmail server
* Your MailChannels SMTP username and password
* `libsasl` installed on your server

## Configure the relay

<Steps>
  <Step title="Add authentication credentials">
    Sendmail stores SMTP credentials in `/etc/mail/access`. Add the following line to the file, replacing the placeholders with your actual MailChannels SMTP username and password:

    ```text /etc/mail/access theme={null}
    AuthInfo:smtp.mailchannels.net "U:MailChannelsSMTPUsername" "P:MailChannelsSMTPPassword" "M:PLAIN"
    ```

    <Warning>
      Do not use your MailChannels Console login username here. The SMTP authentication username is different — it is the account ID provided in your activation email.
    </Warning>
  </Step>

  <Step title="Configure the smart host">
    Edit `/etc/mail/sendmail.mc` and add the following lines to set MailChannels as the smart host. Add lines 1, 3, and 4 around the existing `FEATURE` line (line 2):

    ```text /etc/mail/sendmail.mc theme={null}
    define(`SMART_HOST', `smtp.mailchannels.net')dnl
    FEATURE(`access_db')dnl
    define(`RELAY_MAILER_ARGS', `TCP $h 25')dnl
    define(`ESMTP_MAILER_ARGS', `TCP $h 25')dnl
    ```

    Also comment out the following line in the same file if it is present:

    ```text /etc/mail/sendmail.mc theme={null}
    # FEATURE(`access_db', , `skip')dnl
    ```
  </Step>

  <Step title="Add the X-AuthUser header">
    Append the following lines just before the `MAILER DEFINITIONS` section in `/etc/mail/sendmail.mc`. This adds an authenticated sender header that MailChannels uses to track per-sender reputation:

    ```text /etc/mail/sendmail.mc theme={null}
    LOCAL_CONFIG
    HX-AuthUser: ${auth_authen}
    ```

    <Note>
      The `X-AuthUser` header is only added when the sender is authenticated. Messages without this header are treated as forwarded mail and subject to different policies.
    </Note>
  </Step>

  <Step title="Compile the configuration and restart Sendmail">
    Run the following commands as root to compile the updated configuration files:

    ```bash theme={null}
    cd /etc/mail
    m4 sendmail.mc > sendmail.cf
    makemap hash access < access
    ```

    Then restart Sendmail. On newer distributions:

    ```bash theme={null}
    service sendmail restart
    ```

    On older distributions:

    ```bash theme={null}
    /etc/init.d/sendmail restart
    ```
  </Step>
</Steps>
