Why Voicemail Matters for Business PBX
Voicemail is an essential component of any business phone system. When callers cannot reach an extension -- whether the user is on another call, away from their desk, or outside business hours -- a properly configured voicemail system ensures no message is lost. Asterisk voicemail setup provides a powerful, flexible solution that can deliver messages via email, integrate with visual voicemail clients, and support complex multi-tenant environments.
In this guide, we walk through the complete asterisk voicemail configuration process: from the base voicemail.conf settings, through voicemail to email asterisk integration, to dialplan logic that gracefully routes unanswered calls to the correct mailbox.
Prerequisites: This guide assumes you have Asterisk 18+ installed and a working SIP trunk (such as IPComms). If you need to set up the trunk first, see our Asterisk PJSIP Trunk Setup guide.
Configuring voicemail.conf
The voicemail.conf file is the heart of the Asterisk voicemail setup. It defines global settings, email delivery options, and individual mailbox configurations.
The [general] Section
[general]
; Audio formats - wav49 for email, gsm for storage, wav for playback
format=wav49|gsm|wav
; Message limits
maxmsg=100 ; Maximum messages per mailbox
maxsecs=300 ; Maximum message length (5 minutes)
minsecs=3 ; Minimum message length (skip short recordings)
maxsilence=10 ; Seconds of silence before ending recording
silencethreshold=128 ; Audio threshold for silence detection
; Greeting behavior
skipms=3000 ; Skip forward/backward in milliseconds
maxgreet=60 ; Maximum greeting length in seconds
maxlogins=3 ; Failed login attempts before lockout
; Playback options
saycid=yes ; Announce caller ID before message
envelope=yes ; Play date/time envelope
sayduration=yes ; Announce message duration
saydurationm=2 ; Only announce if longer than 2 minutes
; Navigation
moveheard=yes ; Move heard messages to Old folder
forward_urgent_auto=yes ; Auto-forward urgent messages
; Timezone for message timestamps
tz=eastern
The [default] Context - Mailbox Definitions
; Format: mailbox => password,name,email,pager_email,options
[default]
100 => 1234,John Smith,john@company.com,,attach=yes|delete=no|tz=eastern
101 => 5678,Jane Doe,jane@company.com,,attach=yes|delete=no|tz=eastern
102 => 9012,Bob Wilson,bob@company.com,,attach=yes|delete=yes|tz=pacific
110 => 3456,Sales Dept,sales@company.com,,attach=yes|delete=no|tz=eastern
120 => 7890,Support Team,support@company.com,,attach=yes|delete=no|tz=eastern
Security Tip: Avoid using simple PINs like 1234 in production. Use at least 6-digit PINs and encourage users to change their PIN on first login.
Voicemail to Email Setup
One of the most requested features in any asterisk voicemail configuration is email delivery. The voicemail to email feature sends notifications (with optional audio attachment) whenever a new message arrives.
Email Template Configuration
[general]
; From address
serveremail=voicemail@company.com
fromstring=Company Voicemail
; Email subject line
; Variables: ${VM_NAME}, ${VM_MAILBOX}, ${VM_CALLERID}, ${VM_DUR}, ${VM_DATE}
emailsubject=New Voicemail from ${VM_CALLERID} (${VM_DUR} seconds)
; Email body template
emailbody=Hi ${VM_NAME},\n\nYou have a new voicemail message:\n\n From: ${VM_CALLERID}\n Date: ${VM_DATE}\n Duration: ${VM_DUR} seconds\n Mailbox: ${VM_MAILBOX}\n\n--\nCompany Phone System
; Date format for emails
emaildateformat=%A, %B %d, %Y at %I:%M %p
; Attach audio file to email
attach=yes
; Character set
charset=UTF-8
attach=yes vs delete=yes: Setting attach=yes includes the audio file in the email. If you also set delete=yes, the message is removed from the Asterisk voicemail store after emailing.
Dialplan Integration
The asterisk voicemail setup is only useful when properly integrated into your dialplan. Asterisk provides two key applications: VoiceMail() for sending callers to voicemail, and VoiceMailMain() for retrieving messages.
Dial with Voicemail Fallback
[internal]
; Extension 100 - Ring for 20 seconds, voicemail on no answer or busy
exten => 100,1,NoOp(Calling extension 100 - John Smith)
same => n,Set(TIMEOUT(ring)=20)
same => n,Dial(PJSIP/100,20,tTr)
same => n,GotoIf($["${DIALSTATUS}" = "BUSY"]?busy:unavail)
same => n(busy),VoiceMail(100@default,b)
same => n,Hangup()
same => n(unavail),VoiceMail(100@default,u)
same => n,Hangup()
; Voicemail access
exten => *97,1,Answer()
same => n,VoiceMailMain(${CALLERID(num)}@default)
same => n,Hangup()
Inbound Call Flow with IPComms Trunk
When using an IPComms SIP trunk (server: s1.ipcomms.net, IP: 34.23.59.14), inbound DID calls arrive in a specific context. Here is a complete dialplan that routes calls to extensions with voicemail fallback:
[from-ipcomms]
; Context for inbound calls from IPComms trunk
; Main DID - Route to extension 100 with voicemail
exten => 2125551000,1,NoOp(Inbound call to main DID from ${CALLERID(num)})
same => n,Dial(PJSIP/100,20,tTr)
same => n,GotoIf($["${DIALSTATUS}" = "BUSY"]?busy:unavail)
same => n(busy),VoiceMail(100@default,b)
same => n,Hangup()
same => n(unavail),VoiceMail(100@default,u)
same => n,Hangup()
; Sales DID - Ring group then voicemail
exten => 2125551001,1,NoOp(Inbound to Sales DID)
same => n,Dial(PJSIP/110&PJSIP/111&PJSIP/112,25,tTr)
same => n,VoiceMail(110@default,u)
same => n,Hangup()
; Catch-all for unmatched DIDs
exten => _X.,1,NoOp(Unmatched DID: ${EXTEN})
same => n,VoiceMail(100@default,u)
same => n,Hangup()
TLS/SRTP: For encrypted calls, use port 5061 and add media_encryption=sdes to the endpoint section. See our PJSIP trunk guide for full TLS configuration.
Advanced Voicemail Features
MWI (Message Waiting Indicator) with PJSIP
MWI lights up the voicemail indicator on SIP phones when new messages arrive:
[100]
type=endpoint
context=internal
disallow=all
allow=ulaw
auth=100_auth
aors=100
mailboxes=100@default ; Link MWI to mailbox
[100]
type=aor
max_contacts=1
remove_existing=yes
qualify_frequency=30
[100_auth]
type=auth
auth_type=userpass
username=100
password=SecurePass123!
Storage Options: File-Based vs ODBC Database
File-Based (Default)
- +Simple setup, no database required
- +Easy backup (just copy spool dir)
- -No clustering/HA support
ODBC Database
- +Centralized storage for clusters
- +Database replication/backup
- -Requires database setup
Troubleshooting
| Problem | Solution |
|---|---|
| Email not sending | Check mailq, verify postfix/sendmail is running |
| MWI not lighting up | Add mailboxes=100@default to endpoint |
| Poor audio quality | Use wav format, ensure ulaw codec for SIP |
| "Mailbox does not exist" | Ensure VoiceMail() context matches voicemail.conf |
Debugging Commands
# List mailboxes and message counts
asterisk -rx "voicemail show users"
# Reload voicemail configuration
asterisk -rx "voicemail reload"
# Check MWI subscriptions (PJSIP)
asterisk -rx "pjsip show subscriptions inbound"
Connect Your Asterisk PBX to IPComms
Get a SIP trunk with crystal-clear audio, reliable DID routing to your voicemail system, and US/Canada calling at just $0.01/min.