Voicemail with Email Notification
Voicemail with Email Notification
Set up voicemail boxes that send an email with the voice message attached whenever a new message is left.
Requirements
- A working MTA (mail transfer agent) on the Asterisk server:
sendmail,postfix, ormsmtp voicemail.confconfigured (shown below)
Voicemail Configuration (voicemail.conf)
[general]
format = wav49|wav
serveremail = asterisk@example.com
attach = yes
skipms = 3000
maxsilence = 10
silencethreshold = 128
maxlogins = 3
emaildateformat = %A, %B %d, %Y at %r
emailsubject = New voicemail from ${VM_CALLERID}
emailbody = Hi ${VM_NAME},\n\nYou have a new ${VM_DUR} long voicemail from ${VM_CALLERID} in mailbox ${VM_MAILBOX}.\n\n--Asterisk
[default]
; mailbox => password,name,email,pager,options
100 => 1234,John Smith,john@example.com,,tz=eastern|attach=yes
101 => 5678,Jane Doe,jane@example.com,,tz=eastern|attach=yes|delete=yes
Dialplan
[voicemail-main]
; Direct to voicemail (unavailable greeting)
exten => s,1,NoOp(Sending caller to voicemail)
same => n,VoiceMail(100@default,u)
same => n,Hangup()
; Busy greeting variant
exten => busy,1,VoiceMail(100@default,b)
same => n,Hangup()
[voicemail-check]
; Let users check their voicemail
exten => *98,1,Answer()
same => n,VoiceMailMain(@default)
same => n,Hangup()
; Check a specific mailbox
exten => *99,1,Answer()
same => n,VoiceMailMain(${CALLERID(num)}@default)
same => n,Hangup()
How it works
- VoiceMail(mailbox@context,options): Records a voicemail. The
uflag plays the "unavailable" greeting;bplays the "busy" greeting. - Email delivery: When
attach=yes, Asterisk calls the system mailer to send an email with the audio file attached. Theemailsubjectandemailbodytemplates use Asterisk voicemail variables. - VoiceMailMain(): The voicemail retrieval application. Without arguments, it prompts for a mailbox number. With a mailbox argument, it goes directly to that box.
- delete=yes: When set per-mailbox, the voicemail is deleted from the server after being emailed. Useful when users only check voicemail via email.
Tips
- Test email delivery with
echo "test" | mail -s "test" you@example.comfrom the Asterisk server before relying on voicemail email. - Use
format = wav49to reduce attachment size (GSM-compressed WAV). Fullwavis higher quality but larger. - For external SMTP relay, configure
msmtporssmtpas the system mailer instead of running a full MTA. - Set
maxmsgin[general]to limit how many messages a mailbox can hold (default 100).
User Notes
Know a tip or gotcha for this topic? Share it below and help others.
Contribute a note
Share a tip, gotcha, or practical example. Keep it under 2000 characters. No questions (use the Asterisk community forums for support). Wrap code in backticks.