• News
  • Idefisk
  • Tools
  • Tutorials
  • Forum
  • Reviews
  • VoIP Providers
  • Archives
  • Gallery
ZOIPER SIP softphone
Back to Tutorials

6.43.2. Voicemail Example 2

Example

In this basic example we will show you:
* how to send e-mail notification messages
* how to attach audio files to notification messages
* how to customize the notification messages
* how to use voicemail.conf keywords in order to reduce large amounts of HDD usage
* how to use macros in order to simplify extensions.conf


Requirements - this tutorial is the continuation of VoiceMail example 1. This means that we will use the configuration files (the SIP/IAX2 accounts,the mailbox accounts and the extensions) that were set up there. Here are the configuration files from previos example:
- iax.conf
- sip.conf
- extensions.conf
- voicemail.conf


How to send notification messages - in order to change a notification message we will need a working mail application (for this example we will use sendmail). Check if you have already installed sendmail.
For Fedora:
fedora_mail_check.gif
For Debian:
debian_mail_check.gif

If you don't have sendmail installed (or other application with the same functions - sending mails) you should install it by using either `yum` or `rpm` for Fedora, and `apt-cache` and `apt-get` or `dpkg` for Debian. This example won't cover the installation of those utilities. However if you feel difficulties check sendmail, qmail and postfix home pages.

Returning to Asterisk. By default Asterisk uses "/usr/bin/sendmail -t" as mail application if you are using different mail application or your path is different you should specify it by using `mailcmd` keyword. In our tutorial we will use the same location but we will specify it in order to show how to use this keyword.
mailcmd_sendmail.gif

In order to send a notification message to a certain user we will have to specify his/hers e-mail address. For our example we will use our imaginary company's mail server named mail.company.com
setting_mail_accounts.gif

Let's test it out. In the Asterisk console type `dial 101@internal`. This command will dial extension `101` from the `internal` context. If you have registered your account from your phone, do not answer it. When you see that the voicemail has started recording the messages type `hangup`
making_call_wth_voicemail.gif

And here is the result in our mail:
mail_result_bez_attach.gif

How to send the audio message as an attachment? Asterisk sends the mail with attachment only if the `attach` keyword's value is set to `yes` for the current account (specified either by general or by per-user option). Asterisk sends the first format specified in `format` keyword. In our configuration file this will be the `wav49` format. However we can override this by specifying one of the other formats (that are been specified) with the keyword `attachfmt`. Additionally we will specify attachfmt per-user to the two mailboxes in [bosses] context.
setting_attach.gif

And here is the result:
tmp.gif


How to customize our notification mails - there are ways to customize the notification messages that we are sending. We can adjust almost everything related to the message. We can change the Subject of the mail, the mail's body, the sender, the date format... We are going to use every possible keyword that customize the message. However you may prefer to let some things in their default settings.
Sender - by using the `severemail` keyword we will specify a custom e-mail.
Date format - we will set a custom time/date format by using the `emaildateformat` keyword. Note that the valid arguments at our tutorial
Subject - we will set a custom subject and also disable the `PBX` part of the string. We will use two keywords: `emailsubject` and `pbxskip`
Body - we will set a custom body (the text message) of our notification message by using the `emailbody` keyword
Here is the example of the customization that we made:
mail_customatisation.gif

In our example we are saving two formats. A typical voicemail message with length of about one minute will take about 150KB per file, which makes a 300KB per message. Let every account have approximately twenty messages saved. This makes 6MB per account. We have fourteen accounts which makes approximately 84MB. Now imagine you have one hundred mailboxes, not just fourteen. This will make about 600MB... How about one thousand accounts? Note that we are not saving the large audio formats as wav. We have to make some restrictions in order to reduce the large amount of disk space needed.
Sometimes when a user hears a voicemail greeting, he doesn't leave a message and hangs up - however this will leave an empty voicemail which will take some space. In order to restrict this behavior we will use the `minmessage` keyword. A message with length is less than five seconds can't include much information. That's why we won't save messages with length less than five seconds
	minmessage=5
Sometimes users start recording very long messages. We doubt that anyone will listen a message longer than two minute (most commonly, the messages are containing information such as "It is Peter. The server is down. Call me ASAP." or "Hi, it's Philip. Please call me when you have a completed version of the tutorial."). Let's lower the maximum length of the messages to two minutes.
	maxmessage=120
Sometimes users forget to hang up the call, and this results in very long messages. We will activate the silence detector (by using `maxsilence` and `silencethreshold` keywords). If Asterisk detects (the silencethreshold value will define what is silence and what isn't) a longer silence than maxsilence value, the server will hang up the call.
	silencethreshold=96
	maxsilence=5
We can also set a lower value to the `maxmsg` keyword in order to decrease the maximum amount of voicemail messages per account
maxmsg=20
There is an extreme way to decrease the required space for certain account(s). We will show it on the mailboxes in the [secretary] context. We will send the message as an attachment and then we will delete the message itself.
2010 => 1234,Mila Hook,mila.hook@mail.company.com,,attach=yes|delete=yes
2011 => 1235,John Dow,john.dow@mail.company.com,,attach=yes|delete=yes
2012 => 1236,Dacy Even,dacy.even@mail.company.com,,attach=yes|delete=yes
In this way no messages will be saved on our disk. All messages will be e-mailed on the respective e-mail.

adding_delete.gif

Dealing with many account might cause you lot's of trouble. Especially when it is up to managing `extensions.conf`. Here we will offer you a solution which will simplify the problem. If we look at our extensions.conf we will note that we are creating these extensions for every user:
	exten => 0***,1,Answer()
	exten => 0***,2,VoiceMailMain(****@*******)
	exten => 0***,3,HangUp()

	exten => ***,1,Dial(****/*****)
	exten => ***,2,VoiceMail(****@*******)
	exten => ***,3,HangUp()
How about writing one line for each account? We will use two macros in order to achieve a shorter and easier way of adding new accounts. One of the macros will handle the internal communication between the accounts, the other one will handle the voicemail applications (VoiceMailMain() extension). Since our accounts' names are not numbers and have nothing in common between the accounts' usernames, their mailbox number and their extension we will use variables defined in the [global] section of extensions.conf in order to specify the relation between the mailbox account, the extension number and the SIP or IAX2 account. Here are the macros:
macros.gif

And here are the variable declarations:
adding_vars.gif

Note that we have removed/commented the whole [voicemail] the whole [internal] context and we have added these two extensions, which matches per extension and starts the macros:
using_macros.gif

With this final step we have finished this example. Here are the files after the final editions:
- iax.conf
- sip.conf
- extensions.conf
- voicemail.conf

We will use this example as start point for our next example (in progress) example.

 
User Comments
robert duffer (rest at jerryh dot us)
21 January 2008 18:41:56
I uderstand the tutorial so far, but where do I indicate my SMTP server address for Asterisk? I am new at Asterisk (and Linux), so maybe my question as an obvious answer if I were more familiar with Linux-Asterisk.
Thanks
Sergio (lapostadisergio at gmail dot com)
21 September 2007 12:14:57
WHERE ARE THAT FILES?
Could you say me how I have to write to modify the body of the email? Have I to write in the voicemail.conf file and in particular into the context of the definitions of the mailbox?
THANK YOU VERY MUCH.

I'd like to know where do you learn asterisk because I have try to learn it for my studies.
Perry mensah (pamomens at gmail dot com)
11 May 2007 18:50:18
Good tutorials, unfortunately the final files as you are presenting are not there.

Aslo you dont specify the file you are working on, it will really help if you specify them.

Can you also consider using a third party mail server which is running on a saperate server.

Thanks for the great tutorials
John Gardner (JOHN dot GARDNER at TAGISH dot CO dot UK)
10 May 2007 15:58:44
It started off so well, but then you started editing files and not specifiying what files they were from.
artef (andofetra at gmail dot conf)
25 March 2007 09:29:11
Where are the files you\'ve just said in \"Here are the files after the final editions\"?
 
Add Comment
Name:
Email:
Comment:
In order to prevent automatic posting on our website, we kindly request you to type in the number you see in the picture below.
Image Verification:
 

Latest Headlines:

  • T.38 faxing with Zoiper 2.15 is now easier than ever
    section: voip software
  • Asterisk 1.4.21 Released
    section: Asterisk
  • Asterisk 1.4.20 Released
    section: Asterisk
  • Asterisk 1.4.20-rc2 Released
    section: Asterisk
  • Asterisk 1.4.20-rc1 Now Available
    section: Asterisk
  • News Archives (older news)

Latest Tutorials:

  • Sending Fax from Zoiper to Zoiper using T.38
    added 08/Dec/2008 18:16
  • VMAuthenticate (dialplan application)
    added 01/Mar/2008 15:57
  • Siptronic ST-530
    added 06/Nov/2007 17:57
  • Siemens C455 IP hardphone
    added 05/Nov/2007 10:24
  • Zoiper
    added 22/Oct/2007 17:53

Latest Comments:

  • <a href=http://www.allsneaker.com>Adidas...
    section: Asterisk
  • Supercertified is the leader in supply...
    tutorial: VMAuthenticate (dialplan application)
  • Supercertified is the leader in supply...
    tutorial: Sending Fax from Zoiper to Zoiper using T.38
  • <a href="http://www.supercertified.com/c...
    section: Asterisk
  • Supercertified is the leader in supplyin...
    section: Asterisk
 
contact us at: support@asteriskguru.com - asterisKGuru.com © all rights reserved   |   *asterisk is registered trademark of © Digium™