Skip to main content
This guide walks you through installing and configuring Postfix on an Azure VM to relay all outbound mail through MailChannels Outbound Filtering.
Azure blocks outbound port 25 on VMs. This guide uses port 2525, which MailChannels configures identically to port 25.

Prerequisites

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

Configure the relay

1

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:
sudo apt-get update && sudo apt-get install postfix libsasl2-modules -y
RHEL/CentOS:
sudo yum install postfix cyrus-sasl-plain cyrus-sasl-md5 -y
2

Configure main.cf

Open /etc/postfix/main.cf in a text editor. Find and comment out the following lines if present:
/etc/postfix/main.cf
#default_transport = error
#relay_transport = error
Then append the following configuration to the end of the file:
/etc/postfix/main.cf
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
3

Create the password file

Create /etc/postfix/password with your MailChannels SMTP credentials. The file is space-delimited — do not use tabs:
/etc/postfix/password
smtp.mailchannels.net  <SMTP_username>:<SMTP_password>
Secure the file and generate the Postfix hash map:
chown root:root /etc/postfix/password
chmod 0600 /etc/postfix/password
postmap hash:/etc/postfix/password
4

Restart Postfix

Debian/Ubuntu:
/etc/init.d/postfix restart
RHEL/CentOS:
postfix reload

Verify the configuration

1

Send a test email

Install a mail utility and send a test message to an address you control.Debian/Ubuntu:
sudo apt-get install mailutils -y
RHEL/CentOS:
sudo yum install mailx -y
Then send the test:
echo 'Test Message' | mail -s 'Relay Config Test' you@example.com
2

Check the mail log

Tail the mail log to confirm the message was accepted and cleared from the queue without errors:
tail -f /var/log/maillog
3

Review the MailChannels Host Console

Log in to your MailChannels Host Console and check Log Search to confirm your test message was processed and delivered.