Asterisk Dialplan: Test Mail Server (Latest Versions)
Updated guide for modern Asterisk (PJSIP era): test mail server with real configs, common mistakes, and troubleshooting steps.
Email delivery is a critical part of voicemail in real business deployments. If voicemail cannot reach the user’s inbox, missed calls may never be seen, leading to lost customers and delayed follow-ups.
Asterisk itself does not run a full mail server. Instead, it relies on the Linux system mail configuration to send voicemail notifications through SMTP.
This guide explains how to configure and test a mail server for modern Asterisk (PJSIP-based systems), including Gmail/SMTP relay setups and real troubleshooting steps.
How Voicemail Email Works in Asterisk
- A caller leaves a voicemail
- Asterisk stores the audio file on disk
- Asterisk triggers system mail command
- Linux mail agent sends email via SMTP
Because of this architecture, fixing email issues usually means fixing system mail configuration, not Asterisk itself.
Prerequisites Before Testing Mail
- Working internet connection on server
- Valid SMTP credentials (Gmail, Office365, or company mail server)
- Correct email address defined in
voicemail.conf
Step 1 — Install Mail Utilities on Linux
On Ubuntu/Debian:
sudo apt update
sudo apt install mailutils msmtp msmtp-mta -y
These packages allow Linux to send outgoing emails using SMTP relay.
Step 2 — Configure SMTP Relay (Example: Gmail)
Edit configuration file:
sudo nano /etc/msmtprc
Example Gmail configuration:
defaults
auth on
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile /var/log/msmtp.log
account gmail
host smtp.gmail.com
port 587
from yourgmail@gmail.com
user yourgmail@gmail.com
password YOUR_APP_PASSWORD
account default : gmail
Important:
- Use App Password, not Gmail login password
- Enable 2-factor authentication in Google account
Step 3 — Test Email from Linux Command Line
Before testing inside Asterisk, verify system mail:
echo "Test email from Asterisk server" | mail -s "Mail Test" your@email.com
If this fails, voicemail email will also fail.
Step 4 — Configure Email in voicemail.conf
Open:
sudo nano /etc/asterisk/voicemail.conf
Example mailbox:
[default]
1001 => 1234,Agent 1001,agent1001@example.com
Enable email attachment settings:
attach=yes
delete=no
emailsubject=New voicemail from ${CALLERID(num)}
emailbody=You have received a new voicemail from ${CALLERID(num)}.
Step 5 — Reload Asterisk Configuration
asterisk -rx "module reload app_voicemail.so"
This applies voicemail email configuration without restarting Asterisk.
Step 6 — Perform a Real Voicemail Test
- Call extension 1001
- Do not answer the call
- Leave a voicemail message
- Check email inbox
If configured correctly, email should contain:
- Caller number
- Date/time
- Voicemail audio attachment
Common Mail Delivery Problems
Email Not Sent at All
- SMTP credentials incorrect
- Firewall blocking outbound port 587
- msmtp not installed
Email Sent but No Attachment
attach=yesmissing in voicemail.conf
Email Goes to Spam
- Using Gmail without proper sender identity
- No SPF/DKIM for company domain
Asterisk Logs Show Mail Errors
tail -f /var/log/msmtp.log
asterisk -rvvv
Best Practices for Business Deployments
- Use company SMTP server instead of personal Gmail
- Enable voicemail audio attachment
- Send copies to shared support mailbox
- Integrate voicemail events with CRM or WhatsApp alerts
In modern telecom systems, voicemail email is often the first step toward automation and AI follow-ups.
Key Takeaway
Testing the mail server is essential before relying on voicemail alerts. Asterisk depends on Linux SMTP configuration, so always verify email delivery from command line first.
Once mail works reliably, voicemail becomes a powerful missed-lead recovery mechanism for real business operations.
Want to see API-driven CRM + Telecom workflows in action? Try the WhatsApp bot or explore the demos.
Comments (0)
Be the first to comment.