Set up FreePBX/Asterisk voicemail-to-Email through M365/Google WITHOUT purchasing the system admin module.

How to Configure FreePBX Voicemail-to-Email with CM Relay

I’ve been building FreePBX systems for more than 10 years, and getting voicemail-to-email working reliably has always been one of those tasks that can be more difficult than it should be.

One particularly frustrating issue is testing email delivery. Even when using the FreePBX System Admin module, a test message may be sent from an address such as asterisk@hostname.com instead of the voicemail sender address you configured. This can make troubleshooting mail delivery unnecessarily confusing.

In this guide, I’ll show you how to configure Asterisk/FreePBX to send its email through CM Relay. CM Relay receives the message from your PBX and then securely sends it using your connected Microsoft 365 or Google Workspace/Gmail mailbox.

There are three main parts to the setup:

  1. Connect your mailbox to CM Relay.
  2. Configure the email addresses in FreePBX.
  3. Configure Postfix to use CM Relay as its relay host.

Step 1: Connect Your Mailbox to CM Relay

First, connect the mailbox you want your PBX to send through to your CM Relay account.

For example:

pbx@mydomain.com

This can be a supported Microsoft 365 or Google/Gmail mailbox connected to CM Relay.

If you haven’t done this before, watch our CM Relay setup video:

Watch the CM Relay Setup Video on YouTube

Important: Make note of the email address you connect. We’ll use the same address throughout the FreePBX configuration.


Step 2: Configure the Email Addresses in FreePBX

Log in to your FreePBX web interface.

2.1 Verify the PBX Hostname

Go to:

System Admin → Hostname

Make sure the server has a proper fully qualified hostname, such as:

pbx1.mydomain.com

We’ll use this hostname later when configuring Postfix.

2.2 Configure the Notification Email Address

In the System Admin module, go to the Notification Settings section.

Set the From email address to the mailbox you connected to CM Relay.

For example:

pbx@mydomain.com

2.3 Configure the Voicemail Server Email Address

Next, go to:

Settings → Voicemail Admin → Settings → Email Config

Set Server Email to the same mailbox:

pbx@mydomain.com

At this point, the mailbox connected to CM Relay and the email addresses configured in FreePBX should all match.


Step 3: Configure Postfix to Relay Through CM Relay

Now we’ll configure the underlying Postfix mail server. This is the part that actually tells the PBX to send outgoing email to CM Relay instead of attempting to deliver messages directly to recipient mail servers.

SSH into your Asterisk/FreePBX server using PuTTY, Windows Terminal, or another SSH client.

Log in with an account that has sudo privileges and switch to a root shell:

sudo -i

3.1 Configure the CM Relay Smart Host

Edit the Postfix configuration:

nano /etc/postfix/main.cf

Add or update the following settings:

relayhost = [s1.cmrelay.com]:587

smtp_use_tls = yes
smtp_tls_security_level = encrypt
smtp_tls_loglevel = 1

smtp_sasl_auth_enable = no

smtp_generic_maps = hash:/etc/postfix/generic

The brackets around s1.cmrelay.com are intentional. They tell Postfix to connect directly to the specified CM Relay server instead of performing an MX lookup.

Press Ctrl+X, then Y, then Enter to save the file.


Configure Sender Address Rewriting

Asterisk may generate messages using local addresses such as:

asterisk@pbx1.mydomain.com

or:

root@pbx1.mydomain.com

We want Postfix to rewrite these addresses to the mailbox you connected to CM Relay.

Edit the Postfix generic address map:

nano /etc/postfix/generic

Add entries similar to the following:

asterisk@pbx1.mydomain.com    pbx@mydomain.com
root@pbx1.mydomain.com        pbx@mydomain.com
root@localhost                pbx@mydomain.com
asterisk@localhost            pbx@mydomain.com

Replace the example addresses with your actual PBX hostname and the mailbox you connected to CM Relay.

For example, if your PBX hostname is:

phone.company.com

and your connected mailbox is:

voicemail@company.com

you would use:

asterisk@phone.company.com    voicemail@company.com
root@phone.company.com        voicemail@company.com
root@localhost                voicemail@company.com
asterisk@localhost            voicemail@company.com

Save the file with Ctrl+X, then Y, then Enter.


Apply the Postfix Configuration

Run the following commands one at a time:

postmap /etc/postfix/generic
postfix check
systemctl restart postfix

If postfix check reports warnings or errors, stop and review the configuration before continuing. A typo in main.cf or the generic address map can prevent Postfix from operating correctly.

You can also verify the important settings with:

postconf relayhost
postconf smtp_use_tls
postconf smtp_tls_security_level
postconf smtp_sasl_auth_enable
postconf smtp_generic_maps

You should see settings similar to:

relayhost = [s1.cmrelay.com]:587
smtp_use_tls = yes
smtp_tls_security_level = encrypt
smtp_sasl_auth_enable = no
smtp_generic_maps = hash:/etc/postfix/generic

Testing FreePBX Voicemail-to-Email

Now we’re ready to test the complete path from FreePBX through CM Relay.

The way I normally test this is by creating a temporary Caller ID route in FreePBX.

Go to:

Connectivity → Inbound Routes

Create a new inbound route and configure it as a Caller ID Priority Route. Enter your cell phone number in the CallerID Number field.

For the destination, either:

  • Route the call directly to an existing voicemail box that already has email notifications configured, or
  • Create a temporary virtual extension with voicemail enabled and configure its voicemail email address to point to your email account.

Save the changes and click Apply Config.


Allow the PBX to Register with CM Relay

Before placing the test call, log in to CM Relay and go to the Authorized Devices area.

Click:

Allow New Devices to Connect

Now call your PBX from the cell phone number you configured in the Caller ID route.

Your call should be routed directly to the test voicemail box. Leave a short voicemail and hang up.

FreePBX should generate the voicemail email and hand it to the local Postfix server. Postfix will then establish an encrypted SMTP connection to CM Relay on port 587 and submit the message.

CM Relay will ingest the message, authorize the PBX as a device, and relay the voicemail email using your connected Microsoft 365 or Google mailbox.

You should also see the phone system appear in your Authorized Devices list in CM Relay.


Troubleshooting

If you don’t see the message arriving in CM Relay, SSH back into your FreePBX server.

Run:

tail -f /var/log/maillog

Then leave another test voicemail.

This command displays new entries in the Postfix mail log in real time and is one of the quickest ways to determine where the problem is occurring.

For a successful CM Relay configuration, you should see Postfix attempting to deliver through:

s1.cmrelay.com:587

If you instead see Postfix attempting to connect directly to the recipient’s MX server on port 25, your relayhost configuration is not being applied.

You can also check the mail logs inside CM Relay. Looking at both logs makes troubleshooting much easier:

FreePBX / Asterisk
        ↓
Local Postfix
        ↓
s1.cmrelay.com:587
        ↓
CM Relay
        ↓
Microsoft 365 or Google
        ↓
Recipient

No SMTP Username or Password Required on the PBX

One of the nice things about this setup is that you don’t have to store your Microsoft 365 or Google mailbox password on the FreePBX server.

The PBX simply submits its email to CM Relay. CM Relay handles the connection to your authorized Microsoft 365 or Google account, allowing older or legacy systems such as Asterisk and FreePBX to send email through modern cloud email platforms.


Need Help?

If you’re having trouble getting your FreePBX or Asterisk system working with CM Relay, feel free to contact us at help@twohandstech.com. We’re more than happy to help you get your system configured.

Happy Relaying!

— Spencer

Scroll to Top