Tutorial June 22, 2025 8 min read

How to Set Up Voicemail on Asterisk PBX

A complete walkthrough of Asterisk voicemail configuration, from basic mailbox setup to email notifications and visual voicemail integration.

Voicemail Overview

Asterisk includes a powerful built-in voicemail application (app_voicemail) that supports multiple mailboxes, email delivery of messages, custom greetings, and integration with visual voicemail clients. Whether you have 5 extensions or 500, the setup process follows the same pattern.

Prerequisites: This guide assumes you have a working Asterisk installation with PJSIP endpoints configured. If you need to set up SIP trunks first, see our PJSIP Trunk Setup Guide.

Configuring voicemail.conf

The main voicemail configuration file is /etc/asterisk/voicemail.conf. It has two key sections: [general] for global settings and [default] (or custom context names) for mailbox definitions.

/etc/asterisk/voicemail.conf
[general]
; Format to store voicemail recordings
format=wav49|wav
; Maximum message length in seconds
maxmsg=100
maxsecs=300
minsecs=3
; Maximum greeting length
maxgreet=60
; Skip [instructions] prompt
skipms=3000
; Maximum silence before ending recording
maxsilence=10
; Silence threshold (adjust for noisy environments)
silencethreshold=128
; Send voicemail via email
serveremail=voicemail@yourdomain.com
attach=yes
; Email settings
emailsubject=New voicemail from ${VM_CALLERID}
emailbody=Hi ${VM_NAME},\n\nYou have a new voicemail:\n\nFrom: ${VM_CALLERID}\nDate: ${VM_DATE}\nDuration: ${VM_DUR}\n\nMessage is attached.\n
emaildateformat=%A, %B %d, %Y at %r
; Delete voicemail after emailing (optional)
; delete=yes

[default]
; Format: mailbox => password,name,email,pager,options
100 => 4589,John Smith,john@company.com,,tz=eastern|attach=yes
101 => 7832,Jane Doe,jane@company.com,,tz=eastern|attach=yes
102 => 2941,Bob Wilson,bob@company.com,,tz=central|attach=yes
103 => 6127,Alice Brown,alice@company.com,,tz=pacific|attach=yes

Security Note: Do not use simple or predictable voicemail PINs like 1234 or the extension number. Attackers can exploit voicemail systems to make outbound calls through DISA features.

Dialplan Integration

You need to connect voicemail to your dialplan in two ways: sending unanswered calls to voicemail, and allowing users to check their messages.

/etc/asterisk/extensions.conf
[internal]
; Dial extension, send to voicemail after 20 seconds
exten => _1XX,1,NoOp(Dialing extension ${EXTEN})
 same => n,Dial(PJSIP/${EXTEN},20)
 same => n,GotoIf($["${DIALSTATUS}"="BUSY"]?busy:unavail)
 same => n(busy),VoiceMail(${EXTEN}@default,b)
 same => n,Hangup()
 same => n(unavail),VoiceMail(${EXTEN}@default,u)
 same => n,Hangup()

; Check voicemail - dial *97
exten => *97,1,NoOp(Checking voicemail)
 same => n,VoiceMailMain(${CALLERID(num)}@default)
 same => n,Hangup()

; Check voicemail for specific mailbox - dial *98
exten => *98,1,NoOp(Checking voicemail - any mailbox)
 same => n,VoiceMailMain(@default)
 same => n,Hangup()

The key applications are:

  • VoiceMail(mailbox@context,options) - Records a voicemail. Use b for busy greeting, u for unavailable greeting, or s to skip the greeting.
  • VoiceMailMain(mailbox@context) - Opens the voicemail menu for checking and managing messages.

Email Notifications

For email delivery to work, your Asterisk server needs a working mail transfer agent (MTA). Postfix is the most common choice:

Install and configure Postfix
# Install Postfix
apt install postfix    # Debian/Ubuntu
yum install postfix    # CentOS/RHEL

# Configure as satellite system pointing to your mail relay
# Edit /etc/postfix/main.cf:
relayhost = [smtp.yourdomain.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_security_level = encrypt

# Restart Postfix
systemctl restart postfix

Tip: Set delete=yes in voicemail.conf if users primarily access voicemail via email. This prevents mailbox storage from filling up on the Asterisk server.

Visual Voicemail

Visual voicemail lets users see a list of messages and play them in any order, rather than navigating the phone menu. Asterisk supports this through the MWI (Message Waiting Indicator) and IMAP integration.

MWI (Message Waiting Indicator)

MWI lights up the voicemail indicator on SIP phones when new messages arrive. It works automatically with PJSIP:

pjsip.conf - MWI for endpoint
[100]
type=endpoint
; ... other settings ...
mailboxes=100@default

[100]
type=aor
max_contacts=1
; Subscribe to MWI
mailbox_subscribe=yes

IMAP Storage

For full visual voicemail with IMAP-capable clients, compile Asterisk with IMAP support and configure storage:

voicemail.conf - IMAP storage
[general]
imapserver=mail.yourdomain.com
imapport=993
imapflags=ssl
authuser=asterisk
authpassword=secretpassword
imapfolder=INBOX/Voicemail
imapgreetings=yes

Advanced Options

Timezone Settings

Configure per-mailbox timezones so message timestamps are announced correctly. Set tz=eastern in the mailbox options.

Operator Transfer

Let callers press 0 during the greeting to reach an operator. Set operator=yes in [general] and define the o extension.

Voicemail Groups

Send a single voicemail to multiple mailboxes using the VoiceMail app with comma-separated mailboxes: VoiceMail(100&101&102@default)

Custom Greetings

Users can record busy and unavailable greetings through the VoiceMailMain menu (option 0, then 1 for unavailable, 2 for busy).

Troubleshooting

Common voicemail issues and their solutions:

  • Emails not sending: Check that Postfix is running (systemctl status postfix) and review /var/log/mail.log for delivery errors.
  • MWI light not working: Verify the mailboxes= setting in PJSIP matches the mailbox number in voicemail.conf.
  • Recordings too quiet: Adjust the silencethreshold value or check your phone's microphone gain settings.
  • Wrong timezone announced: Ensure the tz= option is set in the mailbox definition and that zonemessages is configured in [zonemessages].
Debug voicemail from Asterisk CLI
asterisk -rvvv
CLI> voicemail show users
CLI> voicemail show zones
CLI> core set verbose 5
; Now make a test call and watch the output

Need SIP Trunks for Your Asterisk PBX?

IPComms provides reliable SIP trunking with full Asterisk compatibility. Get crystal-clear calls with your voicemail system backed by enterprise-grade infrastructure.

Related Articles