1. MailboxExists - this application allows you to check whether certain mailbox exists or not.
NOTE: This application is valid for Asterisk version 1.0.9 and above.
Purpose and usage
The purpose and usage of this application is to check whether a certain mailbox exists or not. If the mailbox exists then the next executed extension will be the one with priority n+101, where n is the priority of the current extension. If such mailbox does not exist, he next executed extension will be the one with priority n+1.
Below, we will show you how you can use this application.
To see how the application works we recommend to use our IAX softphone Idefisk. You can download it from here. Please also read our tutorial to learn how to configure it to work with Asterisk PBX.
Asterisk PBX configurations
NOTE: This is only an example of what for you can use this application. Of course you can use it and for other things.
We need one registered user in iax.conf file. This is because we are going to use the IAX2 protocol. If you want to use other protocol such as SIP or MGCP, you have to do the configurations below respectively in sip.conf or mgcp.conf.
So, we have registered the user user1
Type=friend means that this user can make and receive calls. Host=dynamic means that the IP is not static but dynamic through a DHCP server. Allow=all means that the line which this user will use, could support all audio codecs. Context=test - this shows that this user is working with the extensions in this context of the configuration file extensions.conf.
First you write the mailbox number. It is not necessary to be a number it could be also a name. In our case it would be numbers. They are followed by the => character. After this character the first argument is the desired password for the mailbox. The password is followed by the name and family name of the user and then his/her e-mail address. You can add and some other options, but we do not need them now. You can learn more about this options in our voicemail.conf tutorial.
In our example, in the context [testmail] we will create a mailbox for the user Anatoliy Kun with mailbox number 1515 and password 1111.
We are ready with our voicemail box. Now, lets take a look at the extensions.conf file.
In our example when somebody dials 5456, the call will be answered by the Answer application. The next executed extension will be the one which contains the MailboxExists application.
This application can take two arguments. The first one is the number of the mailbox. The second one is the context, in the voicemail.conf file, at which this mailbox is created. The mailbox number is obligatory. The context parameter is optional. If you set only the mailbox number then this number will be search at all contexts in the voicemail.conf file. If you set add a context after the mailbox number, this number will be search only within this context.
In our example we have set as arguments in the brackets of the application the following: 1515@testmail. 1515 is the mailbox number. @testmail is the context in the voicemail.conf file, in which the mailbox is set.
In case that this number exists the next executed extension will be the one with priority 103. This extension contains the SentText application. Thanks to it the caller will receive a message. In our case this message has the following text: The mailbox 1515 exists. Then the line will be hung up thanks to the Hangup application.
If the mailbox number does not exist the next executed extension will be the one with priority 3. It also contains the SentText application. Thanks to it, the text message There is no such mailbox, will be displayed on the screen of the caller. Then the line will be hung up by the next extension by the help of the Hangup application.
2. Screenshots of what you can see on your Idefisk and on the CLI of the Asterisk PBX
1) Mailbox exists
2) Mailbox does not exist
3. Additional information
For more information about extensions.conf you can check here.
For more information about iax.conf you can check here.
This application is tested with our IAX softphone Idefisk. You can download it from here. For more information about this softphone please read our tutorial.
If you would like to test this application with the SIP channel you can read our tutorials about the SIP Softphones to learn how to configure them to work with Asterisk PBX