Using the Asterisk VoiceMailMain Application
Learn how to configure Asterisk VoiceMailMain for mailbox login, voicemail retrieval, greetings, mailbox options, and secure dialplan access.
VoiceMailMain is the Asterisk dialplan application that gives a voicemail subscriber access to stored messages and mailbox-management features. A typical user dials a feature code, enters a mailbox number, authenticates with a mailbox password, and then uses the voicemail menu.
This lesson assumes basic familiarity with Asterisk dialplans, extensions, priorities, contexts, and DTMF input. A dialplan is the call-routing logic that maps dialed numbers and priorities to applications. An extension can be a phone number or a feature code such as *99.
VoiceMailMain versus VoiceMail
The names are similar, but the applications serve different parts of the voicemail process.
| Application | Primary caller | Primary purpose | Typical outcome |
|---|---|---|---|
VoiceMail | A caller leaving a message | Send the caller to a mailbox to record a message | The caller records and submits a voicemail |
VoiceMailMain | A mailbox owner or authorized user | Retrieve and administer voicemail | The user reaches a mailbox menu |
After successful login, VoiceMailMain can provide menu options for listening to messages, managing saved or new messages, changing mailbox options, and recording personal greetings. The exact prompts and available choices can vary with the Asterisk version and voicemail configuration.
VoiceMailMain parameters
The application accepts an optional mailbox selection and optional behavior-modifying options. Its commonly used structure is:
VoiceMailMain([mailbox[@context][,options]])A mailbox is a voicemail subscriber identity containing messages, greetings, and settings. The mailbox number is the numeric identifier used to select it. A context is a logical grouping used for dialplan routing or voicemail mailbox lookup.
| Invocation pattern | Mailbox selection behavior | Password behavior | Typical use case |
|---|---|---|---|
VoiceMailMain() | Asterisk prompts the caller for a mailbox number | The caller normally enters that mailbox's password | A shared voicemail access code for many users |
VoiceMailMain(444@default) | Asterisk starts with mailbox 444 in the specified context | The user normally still authenticates with the mailbox password | A dedicated path associated with a known mailbox |
VoiceMailMain(444@default,options) | The mailbox is supplied by the dialplan | Options can change normal behavior, including password verification | Controlled internal workflows that require special handling |
Omitting the mailbox
With an empty argument list, the application uses interactive mailbox selection. This is the normal choice when one feature code should serve many subscribers:
same => n,VoiceMailMain()The caller is prompted for a mailbox number and then for the password associated with that mailbox.
Supplying a mailbox directly
A dialplan can supply a mailbox when the target is known:
same => n,VoiceMailMain(444@default)Supplying the mailbox does not automatically make the path safe for public use. Decide explicitly whether the mailbox owner must still enter a password. A direct mailbox path that removes authentication should be limited to a trusted, already-authenticated internal path.
Options and authentication
VoiceMailMain options alter application behavior. In Asterisk versions that support it, the s option skips the normal mailbox passcode check. The exact option set should be confirmed with the documentation for the installed Asterisk version or the CLI application help.
An authentication bypass is appropriate only when another control has already established the caller's identity, such as a tightly restricted internal feature path. It should not be exposed through a public DID, an unrestricted endpoint context, or a shared feature code. For ordinary subscriber access, omit bypass behavior and require the mailbox password.
Interactive mailbox selection and login flow
When the dialplan invokes VoiceMailMain() without a mailbox argument, the default flow is:
- The caller dials the voicemail access feature code.
- Asterisk starts VoiceMailMain and asks for a mailbox number.
- The caller enters the numeric mailbox identifier.
- Asterisk looks up that mailbox in the configured voicemail context.
- The caller enters the mailbox password.
- After successful authentication, Asterisk presents the voicemail-management menu.
The digits entered by the caller must match the mailbox credentials defined in voicemail.conf. For example, entering 444 selects mailbox 444, and entering 2587 is checked against the password configured for that mailbox.
| Step | Caller action | Asterisk response | Configuration dependency |
|---|---|---|---|
| Dial feature code | Dial *99 | Routes the call to VoiceMailMain | The active dialplan context must contain *99 |
| Enter mailbox number | Enter 444 | Selects mailbox 444 | Mailbox 444 must exist in the selected voicemail context |
| Enter password | Enter 2587 | Checks the mailbox credential | The password must match the mailbox definition |
| Access voicemail menu | Choose menu actions | Plays messages and offers mailbox controls | The login must succeed and voicemail must be available |
Configuring a shared voicemail access code
The following example creates *99 as a shared feature code. Each user selects a mailbox interactively.
exten => *99,1,NoOp(Voicemail access)
same => n,VoiceMailMain()NoOp() means “no operation.” It does not provide a user-facing function, but it marks the call flow and can make console logs easier to understand while troubleshooting. It is optional.
The empty parentheses in VoiceMailMain() are important: they tell Asterisk not to select a mailbox in advance, so the caller is prompted for one.
Place this extension in a dialplan context reachable by the intended users. If an endpoint enters a different context, it may not be able to dial *99. Review Asterisk contexts and dialplan extensions when deciding where the feature code belongs.
Defining the required mailbox
A mailbox must already exist before VoiceMailMain can authenticate its owner. Mailboxes and their associated settings are defined in voicemail.conf. See The Voicemail Conf File for mailbox configuration details.
For the demonstration flow, define mailbox 444 with password 2587 in the appropriate voicemail context. Conceptually, the configuration contains:
[default]
444 => 2587,Example UserThe exact fields available after the mailbox password depend on the voicemail configuration format and Asterisk version. The important values for this example are:
- Mailbox number:
444 - Mailbox password:
2587 - Voicemail context: the context containing mailbox 444
Use a stronger private password in a real deployment. Do not publish or reuse 2587 outside a demonstration.
When voicemail contexts are used, the context must align with the lookup performed by the dialplan. For a direct invocation such as VoiceMailMain(444@default), the mailbox must be present in the default voicemail context. For prompted access, verify that the application's default lookup context is the one containing the intended mailbox.
Direct mailbox access design
A dedicated dialplan path can pass a known mailbox to VoiceMailMain:
[trusted-phones]
exten => *9444,1,NoOp(Access mailbox 444)
same => n,VoiceMailMain(444@default)This design can be useful when a phone or internal workflow is associated with one mailbox. The user should normally still enter the mailbox password. Do not add an authentication-bypass option simply because the mailbox number is known. Caller-ID values and dialed feature codes are not, by themselves, reliable proof of identity.
Testing the configuration
- Confirm that mailbox 444 exists in
voicemail.confand has the expected password. - Confirm that the dialplan containing
*99is loaded in the context used by the test endpoint. - From an authorized phone, dial
*99. - When prompted, enter mailbox number
444. - Enter password
2587for this demonstration only. - Verify that the voicemail-management menu is reached.
- Check that stored messages can be heard if messages exist.
- Navigate to mailbox options and greeting controls.
- Test the greeting workflow without permanently changing a production greeting unless that is intended.
Also test the two selection modes separately. With VoiceMailMain(), verify that the caller is prompted for a mailbox. With VoiceMailMain(444@default), verify that mailbox 444 is selected directly and that the expected password prompt remains in place.
Troubleshooting
The feature code does not reach VoiceMailMain
- Confirm that
*99exists in the active dialplan context. - Confirm that the calling endpoint or inbound route enters that context.
- Check that the dialplan configuration was validated and reloaded after editing.
- Use the
NoOp()marker and Asterisk console output to determine whether the call reaches the expected priority.
For background on how applications execute through priorities, review Asterisk priorities.
Mailbox 444 is rejected
- Verify that mailbox 444 is defined in
voicemail.conf. - Check that it is in the voicemail context used by VoiceMailMain.
- Confirm that voicemail configuration changes were loaded before retesting.
- Check for typing errors in the mailbox number.
The mailbox is accepted but the password fails
- Verify the password assigned to mailbox 444.
- Repeat the mailbox-number sequence to ensure the correct mailbox was selected.
- Check whether the configuration was changed but not applied.
- Reset the credential through a secure administrative process rather than sharing the password in an unsecured channel.
The user is not prompted for a password
- Inspect the active VoiceMailMain arguments for a behavior-modifying option.
- Check whether a direct mailbox path uses an authentication-bypass option such as
s. - Confirm that the call is not reaching a different dialplan extension.
- Restore normal password verification for shared, public, or otherwise untrusted access paths.
Exam-relevant points
VoiceMaildeposits a caller's message;VoiceMailMainprovides subscriber retrieval and administration.VoiceMailMain()prompts for the mailbox number.- A supplied mailbox such as
444@defaultselects the mailbox in advance. - The mailbox must exist in
voicemail.conf, and the password must match the selected mailbox. - The feature-code context must be reachable by the intended endpoints or call routes.
- Authentication-bypass behavior must never be exposed to untrusted callers.