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

> Configure Postfix on an Azure VM to relay outbound mail through MailChannels Outbound Filtering, including SASL authentication and TLS on port 2525.

This guide walks you through installing and configuring Postfix on an Azure VM to relay all outbound mail through MailChannels Outbound Filtering.

<Note>
  Azure blocks outbound port 25 on VMs. This guide uses port 2525, which MailChannels configures identically to port 25.
</Note>

## Prerequisites

* Root or `sudo` access to your Azure VM
* Your MailChannels SMTP username and password

## Configure the relay

<Steps>
  <Step title="Install Postfix">
    Connect to your VM over SSH and install Postfix along with the SASL authentication modules. When prompted during installation, select **Local Only** as the configuration type.

    **Debian/Ubuntu:**

    ```bash theme={null}
    sudo apt-get update && sudo apt-get install postfix libsasl2-modules -y
    ```

    **RHEL/CentOS:**

    ```bash theme={null}
    sudo yum install postfix cyrus-sasl-plain cyrus-sasl-md5 -y
    ```
  </Step>

  <Step title="Configure main.cf">
    Open `/etc/postfix/main.cf` in a text editor. Find and comment out the following lines if present:

    ```text /etc/postfix/main.cf theme={null}
    #default_transport = error
    #relay_transport = error
    ```

    Then append the following configuration to the end of the file:

    ```text /etc/postfix/main.cf theme={null}
    relayhost = [smtp.mailchannels.net]:2525
    smtp_sasl_auth_enable = yes
    smtp_sasl_password_maps = hash:/etc/postfix/password
    smtp_sasl_security_options = noanonymous
    smtpd_sasl_authenticated_header = yes
    smtp_tls_security_level = encrypt
    ```
  </Step>

  <Step title="Create the password file">
    Create `/etc/postfix/password` with your MailChannels SMTP credentials. The file is space-delimited — do not use tabs:

    ```text /etc/postfix/password theme={null}
    smtp.mailchannels.net  <SMTP_username>:<SMTP_password>
    ```

    Secure the file and generate the Postfix hash map:

    ```bash theme={null}
    chown root:root /etc/postfix/password
    chmod 0600 /etc/postfix/password
    postmap hash:/etc/postfix/password
    ```
  </Step>

  <Step title="Restart Postfix">
    **Debian/Ubuntu:**

    ```bash theme={null}
    /etc/init.d/postfix restart
    ```

    **RHEL/CentOS:**

    ```bash theme={null}
    postfix reload
    ```
  </Step>
</Steps>

## Verify the configuration

<Steps>
  <Step title="Send a test email">
    Install a mail utility and send a test message to an address you control.

    **Debian/Ubuntu:**

    ```bash theme={null}
    sudo apt-get install mailutils -y
    ```

    **RHEL/CentOS:**

    ```bash theme={null}
    sudo yum install mailx -y
    ```

    Then send the test:

    ```bash theme={null}
    echo 'Test Message' | mail -s 'Relay Config Test' you@example.com
    ```
  </Step>

  <Step title="Check the mail log">
    Tail the mail log to confirm the message was accepted and cleared from the queue without errors:

    ```bash theme={null}
    tail -f /var/log/maillog
    ```
  </Step>

  <Step title="Review the MailChannels Host Console">
    Log in to your [MailChannels Host Console](https://console.mailchannels.net) and check **Outbound > Activity > Log Search** to confirm your test message was processed and delivered.
  </Step>
</Steps>
