Voicemail with Email Notification

Features Asterisk 18+ -- Last reviewed 2026-08-22 voicemail email notifications Found this useful? Upvote it. ×

Voicemail with Email Notification

This recipe adds reliable email delivery to an existing app_voicemail mailbox. It focuses on the sendmail-compatible command Asterisk invokes, attachment choices, end-to-end testing, and retention risk.

For mailbox creation, dialplanThe core call-routing configuration of Asterisk, written mostly in extensions.conf as contexts, extensions, and priorities that decide how every call is handled. Full definition → routing, VoiceMailMain(), and PJSIPThe modern SIP channel driver in Asterisk (chan_pjsip), replacing the older chan_sip. Configured in pjsip.conf using endpoints, AORs, auths, and transports. message waiting indicators, start with Setting Up VoicemailAsterisk's built-in voice messaging system (app_voicemail), configured in voicemail.conf with mailboxes per user. in Asterisk.

On this page

Requirements

Postfix, Exim, Sendmail, or an msmtp sendmail wrapper can provide the interface. Installing a package alone is not enough. The command path, relay configuration, sender policy, and network delivery must all work for the Asterisk service.

Voicemail configuration

[general]
format = wav
serveremail = asterisk@example.com
attach = yes
mailcmd = /usr/sbin/sendmail -t
maxmsg = 100
maxsecs = 180
minsecs = 3
maxsilence = 0
minpassword = 6
emaildateformat = %A, %B %d, %Y at %r
emailsubject = New voicemail from ${VM_CALLERID}
emailbody = Hello ${VM_NAME},\n\nYou have a ${VM_DUR} voicemail from ${VM_CALLERID} in mailbox ${VM_MAILBOX}.\n\nAsterisk PBX

[zonemessages]
eastern = America/New_York|'vm-received' Q 'digits/at' IMp

[default]
200 => 739182,Alice Smith,alice@example.com,,tz=eastern|attach=yes
201 => 825406,Bob Jones,bob@example.com,,tz=eastern|attach=yes

Replace the example domain, addresses, and PINs. The eastern zone is defined before it is assigned to the mailboxes. The example disables silence detection with maxsilence = 0; see Voicemail maxsilence Must Be Less Than minsecs before enabling it.

What Asterisk sends

When a caller leaves a retained message, app_voicemail builds the notification and passes it to mailcmd. With attach = yes, it adds a recorded audio file. Template variables include:

Variable Value
${VM_NAME} Mailbox subscriber name
${VM_DUR} Message duration
${VM_MSGNUM} Message number
${VM_MAILBOX} Mailbox identifier
${VM_CALLERID} Formatted caller IDThe calling party number (and optionally name) presented on an outbound call, set from the endpoint or manipulated in the dialplan.
${VM_DATE} Message date and time

The system mail transport handles relay authentication, DNS delivery, retries, bounces, and sender reputation after Asterisk hands off the message.

Dialplan

Send an unavailable caller to mailbox 200:

[internal]
exten => 200,1,Dial(PJSIP/200,25)
same => n,GotoIf($["${DIALSTATUS}" = "BUSY"]?busy)
same => n,GotoIf($["${DIALSTATUS}" = "NOANSWER"]?unavail)
same => n,GotoIf($["${DIALSTATUS}" = "CHANUNAVAIL"]?unavail)
same => n,Hangup()
same => n(unavail),VoiceMail(200@default,u)
same => n,Hangup()
same => n(busy),VoiceMail(200@default,b)
same => n,Hangup()

Let a user check the mailbox inferred from caller ID, or prompt for another mailbox:

[internal]
; Check the caller's own mailbox
exten => *98,1,VoiceMailMain(${CALLERID(num)}@default)
same => n,Hangup()

; Prompt for a mailbox number
exten => *97,1,VoiceMailMain(@default)
same => n,Hangup()

VoiceMailMain(${CALLERID(num)}@default) does not prompt the caller to choose an arbitrary mailbox. It selects the mailbox matching the caller ID.

Attachment formats

format controls which copies Asterisk records. Multiple values such as wav49|wav store multiple files for each message. The first format is normally selected for the attachment, but the per-mailbox attachfmt option can choose another recorded format:

[general]
format = wav49|wav

[default]
200 => 739182,Alice Smith,alice@example.com,,attach=yes|attachfmt=wav

Compressed formats reduce attachment size. Confirm that recipients and downstream systems can open the selected type. IMAP voicemail storage uses only the first configured recording format.

Back up before changing formats

Do not change the configured format list after mailboxes contain messages unless you reconcile the stored files for every existing message. Convert, add, or remove recordings so they match the new list. Upstream warns that an unreconciled change can disrupt message retrieval and management.

Test the complete path

Confirm that the configured executable exists:

test -x /usr/sbin/sendmail && echo "sendmail interface found"

Reload voicemail after configuration changes:

asterisk -rx "voicemail reload"

Then call the extensionA dialplan entry that matches a dialed number or pattern within a context and triggers a sequence of prioritized steps. and leave a message longer than minsecs. Verify all of the following:

  1. The message appears in the mailbox.
  2. Asterisk invokes the configured mail command without an error.
  3. The mail transport accepts and relays the message.
  4. The recipient receives the expected subject, body, and playable attachment.
  5. Delivery still works when Asterisk runs under its normal service account.

Inspect the Asterisk log and the transport log or system journal when any stage fails. A command such as mail -s can test a separately installed mail client, but it does not verify Asterisk's templates, attachment selection, command path, or service permissions.

Delete after email

The per-mailbox delete=yes option removes the server copy after notification:

[default]
200 => 739182,Alice Smith,alice@example.com,,attach=yes|delete=yes

Email becomes the only retained copy

Enable delete=yes only after end-to-end delivery is reliable and monitored. A rejected message, filtering rule, lost attachment, or retention failure may otherwise leave no voicemail available through VoiceMailMain(). Confirm backup and compliance requirements before removing the server copy.

MWI is separate

Email notification does not configure a phone's message waiting indicator. For unsolicited MWI, set mailboxes = 200@default on the PJSIP endpointIn PJSIP configuration, the SIP entity Asterisk communicates with: a phone, trunk, or other user agent. Defined by an endpoint section in pjsip.conf.. For phone-initiated subscriptions, associate the mailbox with the AoR. The voicemail setup guide covers both models.

Troubleshooting

No message is generated. Verify the mailbox identifier and contextA named section of the dialplan that groups extensions. Calls enter a specific context and can only reach extensions visible from it, making contexts the basic unit of call routing and security., confirm that the recording exceeds minsecs, and inspect the Asterisk log.

Message is stored but no mail process runs. Check mailcmd, executable permissions, and the Asterisk service account.

Transport accepts the message but it never arrives. Inspect the mail queueAn Asterisk call queue (app_queue) that parks incoming calls and distributes them to logged-in agents according to a chosen ring strategy. and delivery logs. Confirm relay credentials, DNS, sender policy, spam filtering, and attachment limits.

Email arrives without playable audio. Confirm attach=yes, the recorded format list, any per-mailbox attachfmt, and the recipient's supported media types.

MWI does not light. Configure PJSIP MWI separately. Successful email delivery does not imply that a phone has subscribed to mailbox state.

Primary sources

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.

Moderated before publishing. Email never shown.
Related Snippets