Comedian Mail

One of the most popular (or, arguably, unpopular) features of any modern telephone system is voicemail. Asterisk has a reasonably flexible voicemail system named Comedian Mail.[83] Some of the features of Asterisk’s voicemail system include:

And that’s just the tip of the iceberg!

The default version of the /etc/asterisk/voicemail.conf file requires a few tweaks in order to provide a configuration that will be suitable to most situations.

We’ll begin by going through the various options you can define in voicemail.conf, and then we’ll provide a sample configuration file with the settings we recommend for most deployments.

The voicemail.conf file contains several sections where parameters can be defined. The following sections detail all the options that are available.

The [general] Section

The first section, [general], allows you to define global settings for your voicemail system. The available options are listed in Table 8.1, “[general] section options for voicemail.conf”.

Table 8.1. [general] section options for voicemail.conf

OptionValue/ExampleNotes
format

wav49|gsm|wav

For each format listed, Asterisk will create a separate recording in that format whenever a message is left. The benefit of this is that some transcoding steps may be saved if the stored format is the same as the codec used on the channel. We like wav because it is the highest quality, and wav49 because it is nicely compressed and easy to email. We don’t like gsm due to it’s scratchy sound, but it enjoys some popularity.[a]
serveremailuser@domainWhen an email is sent from Asterisk, this is the email address that it will appear to come from.[b]
attachyes,noIf an email address is specified for a mailbox, this determines whether the messages is attached to the email (if not, a simple message notification is sent).
maxmsg9999By default Asterisk will only allow a maximum of 100 messages to be stored per user. For users who delete messages, this is no problem. For people who like to save their messages, this space can get eaten up quickly. With the size of hard drives these days, you could easily store thousands of messages for each user, so our current thinking is to set this to the maximum and let the users manage things from there.
maxsecs0This type of setting was useful back in the days when a large voicemail system might have only 40 MB[c] of storage: it was necessary to limit the system because it was easy to fill up the hard drive. This setting can be annoying to callers (although it does force them to get to the point, so some people like it). Nowadays, with terabyte drives becoming common, there is no reason not to set this to a high value. Two considerations are: 1) if a channel gets hung in a mailbox, it’s good to set some sort of value so it doesn’t stay there for days, but 2) if a user wants to use her mailbox to record notes to herself, she won’t appreciate it if you cut her off after three minutes. A setting somewhere between 600 seconds (10 minutes) and 3600 seconds (1 hour) will probably be about right.
minsecs4Many folks will hang up instead of leaving a message when they call somebody and get voicemail. Sometimes this hangup happens after recording has started, so the mailbox owner gets an annoying two-second message of somebody hanging up. This setting ensures that Asterisk will ignore messages that are shorter than the configured minimum length. You should take care not to set this to a value that is too high, though, because then a message like “Hey it’s me give me a call” (which can be said in less than one second) will get lost, and you’ll get complaints of messages disappearing. Three seconds seems to be about right. To discourage people from leaving ultra-short messages that might be discarded, you can request callers to identify themselves and leave some information about why they called.
maxgreet1800You can define the maximum greeting length if you want. Again, since storage is not a problem and setting this too low will annoy your more verbose users, we suggest setting this to a high value and letting your users figure it out an appropriate length for themselves.
skipms3000When listening to messages, users can skip ahead or backwards by pressing (by default) * and #. This setting indicates the length of the jump (in milliseconds).
maxsilence5This setting defines the maximum time for which the caller can remain silent before the recording is stopped. We like to set this setting to one second longer than minsecs (if you set it equal to or greater than minsecs, you will get a warning).
silencethreshold128You can fine-tune the silence sensitivity of Asterisk to better define what qualifies as silence. In practice, this is seldom a good idea, since you cannot control the volumes of all the calls you’ll be getting from different places. It’s best to leave this at the default.
maxlogins3This little security feature is intended to make brute-force attacks on your mailbox passwords more time-consuming. If a bad password is received this many times, voicemail will hang up and you’ll have to call back in to try again. Note that this will not lock up the mailbox. Patient snoopers can continue to try to log into your mailbox as many times as they like, they’ll just have to call back every third attempt. If you have a lot of ham-fingered users, you can set this to something like 5.
moveheardyesThis setting will move listened-to messages to the Old folder. We recommend leaving this at the default.
forward _ urgent _ autonoSetting this to yes will preserve the original urgency setting of any messages the user receives and then forwards on. If you leave it at no, users can set the urgency level themselves on messages that they forward.
userscontextdefaultIf you use the users.conf file (we don’t), you can define here the context where entries are registered.
externnotify/path/to/scriptIf you wish to run an external app whenever a message is left, you can define it here.
smdienablenoIf you are using Asterisk as a voicemail server on a PBX that supports SMDI, you can enable it here.
smdiport/dev/ttyS0Here is where you would define the SMDI port that messages between Asterisk and the external PBX would pass across.
externpass/path/to/scriptAny time the password on a mailbox is changed, the script you define here will be notified of the context, mailbox, and new password. The script will then be responsible for updating voicemail.conf (the Asterisk voicemail app will not update the password if this parameter is defined).
externpassnotify/path/to/scriptAny time the password on a mailbox is changed, the script you define here will be notified of the context, mailbox, and new password. Asterisk will handle updating the password in voicemail.conf. If you have defined externpass, this option will be ignored.
externpasscheck/usr/local/bin/voicemailpwcheck.pySee the sidebar following this table for a description of this option.
directoryintrodir-introThe Directory() dialplan application uses the voicemail.conf file to search by name from an auto attendant. There is a default prompt that plays, called dir-intro. If you want, you can specify a different file to play instead.
charsetISO-8859-1If you need a character set other than ISO-8859-1 (a.k.a Latin 1) to be supported, you can specify it here.
adsifdn0000000FUse this option to configure the Feature Descriptor Number.[d]
adsisec9BDBF7ACUse this option to configure the security lock code.
adsiver1This specifies the ADSI voicemail application version number.
pbxskipyesIf you do not want emails from your voicemail to have the string [PBX] added to the subject, you can set this to yes.
fromstringThe Asterisk PBXYou can use this setting to configure the From: name that will appear in emails from your PBX.
usedirectoryyesThis option allows users composing messages from their mailboxes to take advantage of the Directory.
odbcstorage <item from res_odbc.conf> If you want to store voice messages in a database, you can do that using the Asterisk res_odbc connector. Here, you would set the name of the item in the res_odbc file. For details, see Chapter 22, Clustering.
odbctable <table name> This setting specifies the table name in the database that the odbcstorage setting refers to. For details, see Chapter 22, Clustering.
emailsubject[PBX]: New message ${VM_MSGNUM} in mailbox ${VM_MAILBOX}When Asterisk sends an email, you can use this setting to define what the Subject: line of the email will look like. See the voicemail.conf.sample file for more details.
emailbodyDear ${VM_NAME}:\n\n\tjust wanted to let you know you were just left a ${VM_DUR} long message (number ${VM_MSGNUM})\nin mailbox ${VM_MAILBOX u might\nwant to check it when you get a chance. Thanks!\n\n\t\t\t\t--Asterisk\n When Asterisk sends an email, you can use this setting to define what the body of the email will look like. See the voicemail.conf.sample file for more details.
pagerfromstringThe Asterisk PBXWe don’t actually know anybody who uses pagers anymore (nor can we recall having seen one in many years), but if you have one of these historical oddities and you want to customize what Asterisk sends with its pager notification, presumably you can do that with this. A very practical usage of this feature for short message voicemail notifications is to send a message to an email to SMS gateway.
pagersubjectNew VMAs above.
pagerbodyNew ${VM_DUR} long msg in box ${VM_MAILBOX}\nfrom ${VM_CALLERID}, on ${VM_DATE}The formatting for this uses the same rules as emailbody.
emaildateformat%A, %d %B %Y at %H:%M:%SThis option allows you to specify the date format in emails. Uses the same rules as the C function STRFTIME.
pagerdateformat%A, %d %B %Y at %H:%M:%SThis option allows you to specify the date format in pager. Uses the same rules as the C function STRFTIME.
mailcmd/usr/sbin/sendmail -tIf you want to override the default operating system application for sending mail, you can specify it here.
pollmailboxesno, yesIf the contents of mailboxes are changed by anything other than app_voicemail (such as external applications or another Asterisk system), setting this to yes will cause app_voicemail to poll all the mailboxes for changes, which will trigger proper message waiting indication (MWI) updates.
pollfreq30Used in concert with pollmailboxes, this option specifies the number of seconds to wait between mailbox polls.
imapgreetingsno, yesThis enables/disables remote storage of greetings in the IMAP folder. For more details, see Chapter 18, External Services.
greetingsfolderINBOXIf you’ve enabled imapgreetings, this parameter allows you to define the folder your greetings will be stored in (defaults to INBOX).
imapparentfolderINBOXIMAP servers can handle parent folders in different ways. This field allows you to specify the parent folder for your mailboxes. For more details, see Chapter 7, Outside Connectivity.

[a] The separator that is used for each format option must be the pipe (|) character.

[b] Sending email from Asterisk can require some careful configuration, because many spam filters will find Asterisk messages suspicious and will simply ignore them. We talk more about how to set email for Asterisk in Chapter 18, External Services.

[c] Yes, you read that correctly: megabytes.

[d] The Analog Display Services Interface is a standard that allows for more complex feature interactions through the use of the phone display and menus. With the advent of VoIP telephones, ADSI’s popularity has decreased in recent years.


Part of the [general] section is an area that is referred to as advanced options. These options (listed in Table 8.2, “Advanced options for voicemail.conf”) are defined in the same way as the other options in the [general] section, but they can also be defined on a per-mailbox basis, overriding whatever is defined under [general] for that particular setting.

Table 8.2. Advanced options for voicemail.conf

OptionValue/ExampleNotes
tzeastern, european, etc.Specifies the zonemessages name, as defined in the [zonemessages] section, discussed in the next section.
localede_DE.utf8, es_US.utf8, etc.Used to define how Asterisk generates date/time strings in different locales. To determine the locales that are valid on your Linux system, type locale -a at the shell.
attachyes, noIf an email address is specified for a mailbox, this determines whether the messages are attached to the email notifications (otherwise, a simple message notification is sent).
attachfmtwav49, wav, etc.If attach is enabled and messages are stored in different formats, this defines which format is sent with the email notifications. Often wav49 is a good choice, as it uses a better compression algorithm and thus will use less bandwidth.
saycidyes, noThis command will state the caller ID of the person who left the message.
cidinternalcontexts<context>, <another context>Any dialplan contexts listed here will be searched in an attempt to locate the mailbox context, so that the name associated with the mailbox number can be spoken. The voicemail box number needs to match the extension number that the call came from, and the voicemail context needs to match the dialplan context.[a]
saydurationyes, noThis command will state the length of the message.
saydurationm2Use this to specify the minimum duration of a message to qualify for its length being played back. For example, if you set this to 2, any message less than 2 minutes in length will not have its length stated.
dialout <context> If allowed, users can dial out from their mailboxes. This is considered a very dangerous feature in a phone system (mainly because many voicemail users like to use 1234 as their password), and is therefore not recommended. If you insist on allowing this, make sure you have a second level of password in the dialplan where another password is specified. Even so, this is not a safe practice.
sendvoicemailyes, noThis allows users to compose messages to other users from within their mailboxes.
searchcontextsyes, noThis allows voicemail applications in the dialplan to not have to specify the voicemail context, since all contexts will be searched. This is not recommended.
callback <context> This specifies which dialplan context to use to call back to the sender of a message. The specified context will need to be able to handle dialing of numbers in the format in which they are received (for example, the country code may not be received with the caller ID, but might be required for the outgoing call).
exitcontext <context> There are options that allow the callers to exit the voicemail system when they are in the process of leaving a message (for example, pressing 0 to get an operator). By default, the context the caller came from will be used as the exit context. If desired, this setting will define a different context for callers exiting the voicemail system.
reviewyes, noThis should almost always be set to yes (even though it defaults to no). People get upset if your voicemail system does not allow them to review their messages prior to delivering them.
operatoryes, noBest practice dictates that you should allow your callers to “zero out” from a mailbox, should they not wish to leave a message. Note that an o extension (not “zero,” “oh”) is required in the exitcontext in order to handle these calls.
envelopeno, yesYou can have voicemail play back the details of the message before it plays the actual message. Since this information can also be accessed by pressing 5, we generally set this to no.
deleteno, yesAfter an email message notification is sent (which could include the message itself), the message will be deleted. This option is risky, because even though a message was emailed, it is no guarantee that it was received (spam filters seem to love to delete Asterisk voicemail messages). Point being: on a new system, leave this at no until you are certain that no messages are being lost due to spam filters.
volgain0.0This setting allows you to increase the volume of received messages. Volume used to be a problem in older releases of Asterisk, but has not been an issue for many years. We recommend leaving this at the default. The sox utility is required for this to work.
nextaftercmdyes, noThis handy little setting will save you some time, as it takes you directly to the next message once you’ve finished dealing with the current message.
forcenameyes, noThis strange little setting will check if the mailbox password is the same as the mailbox number. If it is, it will force the user to change his voicemail password and record his name.
forcegreetingsyes, noAs above, but for greetings.
hidefromdirno, yesIf you wish, you can hide specific mailboxes from the Directory() application using this setting.
tempgreetwarnyes, noSetting this to yes will warn the mailbox owner that she has a temporary greeting set. This can be a useful reminder when people return from trips or vacations.
passwordlocationspooldirIf you want, you can have mailbox passwords stored in the spool folder for each mailbox.[b]
messagewrapno, yesIf this is set to yes, when the user has listened to the last message, pressing next (6) will take him to the first message. Also, pressing previous (4) when at the first message will take the user to the last message.
minpassword6This option enforces a minimum password length. Note that this does not prevent the users from setting their passwords to something that’s easy to guess (such as 123456).
vm-passwordcustom_soundIf you want, you can specify a custom sound here to use for the password prompt in voicemail.
vm-newpasswordcustom_soundIf you want, you can specify a custom sound here to use for the “Please enter your new password followed by the pound key” prompt in voicemail.
vm-passchangedcustom_soundIf you want, you can specify a custom sound here to use for the “Your password has been changed” prompt in voicemail.
vm-reenterpasswordcustom_soundIf you want, you can specify a custom sound here to use for the “Please reenter your password followed by the pound key” prompt in voicemail.
vm-mismatchcustom_soundIf you want, you can specify a custom sound here to use for the “The passwords you entered and reentered did not match” prompt in voicemail.
vm-invalid-passwordcustom_soundIf you want, you can specify a custom sound here to use for the “That is not a valid password. Please try again” prompt in voicemail.
vm-pls-try-againcustom_soundIf you want, you can specify a custom sound here to use for the “Please try again” prompt in voicemail.
listen-control-forward-key#You can use this setting to customize the fast forward key.
listen-control-reverse-key*You can use this setting to customize the rewind key.
listen-control-pause-key0You can use this setting to customize the pause/unpause key.
listen-control-restart-key2You can use this setting to customize the replay key.
listen-control-stop-key13456789You can use this setting to customize the interrupt playback key.
backupdeleted0This setting will allow you to specify how many deleted messages are automatically stored by the system. This is similar to a recycle bin. Setting this to 0 disables this feature. Up to 9999 messages can be stored, after which the oldest message will be erased each time another message is deleted.

[a] Yes, we found this a bit confusing too.

[b] Typically the spool folder is /var/spool/asterisk/, and it can be defined in /etc/asterisk/asterisk.conf.


The [zonemessages] Section

The next section of the voicemail.conf file is the [zonemessages] section. The purpose of this section is to allow time zone–specific handling of messages, so you can play back to the user messages with the correct timestamps. You can set the name of the zone to whatever you need. Following the zone name, you can define which time zone you want the name to refer to, as well as some options that define how timestamps are played back. You can look at the ~/src/asterisk-complete/asterisk/1.8/configs/voicemail.conf.sample file for syntax details. Asterisk includes the examples shown in Table 8.3, “[zonemessages] section options for voicemail.conf”.

Table 8.3. [zonemessages] section options for voicemail.conf

Zone nameValue/ExampleNotes
easternAmerica/New_York|'vm-received' Q 'digits/at' IMpThis value would be suitable for the eastern time zone (EST/EDT).
centralAmerica/Chicago|'vm-received' Q 'digits/at' IMpThis value would be suitable for the central time zone (CST/CDT).
central24America/Chicago|'vm-received' q 'digits/at' H N 'hours'This value would also be suitable for CST/CDT, but would play back the time in 24-hour format.
militaryZulu|'vm-received' q 'digits/at' H N 'hours' 'phonetic/z_p'This value would be suitable for Universal Time Coordinated (Zulu time, formerly GMT).
europeanEurope/Copenhagen|'vm-received' a d b 'digits/at' HMThis value would be suitable for Central European time (CEST).

The Contexts Section

All the remaining sections in the voicemail.conf file will be the voicemail contexts, which allow you to segregate groups of mailboxes.

In many cases, you will only need one voicemail context, commonly named [default]. This is worth noting, as it will make things simpler in the dialplan: all the voicemail-related applications assume the context default if no context is specified. In other words, if you don’t require separation of your voicemail users, use default as your one and only voicemail context.

The format for the mailboxes is as follows:

mailbox => password[,FirstName LastName[,email addr[,pager addr[,options[|options]]]]]

Note

The pipe character (|) used to be more popular in Asterisk. For the first few years, it was used as the standard delimiter. More recently, it has almost completely been replaced by the comma; however, there are still a few places where the pipe is used. One of them is in voicemail.conf: for example, as a separator for any mailbox-specific options, and also as the separator character in the format= declarative. You’ll see this in our upcoming example, as well as in the voicemail.conf.sample file.

The parts of the mailbox definition are:

mailbox

This is the mailbox number. It usually corresponds with the extension number of the associated set.

password

This is the numeric password that the mailbox owner will use to access her voicemail. If the user changes her password, the system will update this field in the voicemail.conf file.

FirstName LastName

This is the name of the mailbox owner. The company directory uses the text in this field to allow callers to spell usernames.

email address

This is the email address of the mailbox owner. Asterisk can send voicemail notifications (including the voicemail message itself, as an attachment) to the specified email box.

pager address

This is the email address of the mailbox owner’s pager or cell phone. Asterisk can send a short voicemail notification message to the specified email address.

options

This field is a list of options for setting the mailbox owner’s time zone and overriding the global voicemail settings. There are nine valid options: attach, serveremail, tz, saycid, review, operator, callback, dialout, and exitcontext. These options should be in option = value pairs, separated by the pipe character (|). The tz option sets the user’s time zone to a time zone previously defined in the [zonemessages] section of voicemail.conf, and the other eight options override the global voicemail settings with the same names.

The mailboxes you define in your voicemail.conf file might look like the following examples:

[default]
100 => 5542,Mike Loukides,mike@shifteight.org
101 => 67674,Tim OReilly,tim@shifteight.org
102 => 36217,Mary JonesSmith,mary.jones-smith@shifteight.org

; *** This needs to all be on the same line
103 => 5426,Some Guy,,,dialout=fromvm|callback=fromvm
|review=yes|operator=yes|envelope=yes

[shifteight]
100 => 0107,Leif Madsen,leif@shifteight.org
101 => 0523,Jim VanMeggelen,jim@shifteight.org,,attach=no|maxmsg=100
102 => 11042,Tilghman Lesher,,,attach=no|tz=central

Warning

The Asterisk directory cannot handle the concept of a family name that is anything other than a simple word. This means that family names such as O’Reilly, Jones-Smith, and yes, even Van Meggelen must have any punctuation characters and spaces removed before being added to voicemail.conf.

The contexts in voicemail.conf are an excellent and powerful concept, but you will likely find that the default context will be all that you need in normal use.

An Initial voicemail.conf File

We recommend the following sample as a starting point. You can refer to ~/asterisk-complete/asterisk/1.8/configs/voicemail.conf.sample for details on the various settings:

; Voicemail Configuration

[general]
format=wav49|wav
serveremail=voicemail@shifteight.org
attach=yes
skipms=3000
maxsilence=10
silencethreshold=128
maxlogins=3
emaildateformat=%A, %B %d, %Y at %r
pagerdateformat=%A, %B %d, %Y at %r
sendvoicemail=yes ; Allow the user to compose and send a voicemail while inside

[zonemessages]
eastern=America/New_York|'vm-received' Q 'digits/at' IMp
central=America/Chicago|'vm-received' Q 'digits/at' IMp
central24=America/Chicago|'vm-received' q 'digits/at' H N 'hours'
military=Zulu|'vm-received' q 'digits/at' H N 'hours' 'phonetic/z_p'
european=Europe/Copenhagen|'vm-received' a d b 'digits/at' HM

[shifteight.org]
100 => 1234,Leif Madsen,leif@shifteight.org
101 => 1234,Jim Van Meggelen,jim@shifteight.org
102 => 1234,Russell Bryant,russell@shifteight.org
103 => 1234,Jared Smith,jared@shifteight.org

Note

Setting up a Linux server to handle the sending of email is a Linux administration task that is beyond the scope of this book. You will need to test your voicemail to email service to ensure that the email is being handled appropriately by the Mail Transfer Agent (MTA),[85] and that downstream spam filters are not rejecting the messages (one reason this might happen is if your Asterisk server is using a hostname in the email body that does not in fact resolve to it).



[83] This name was a play on words, inspired in part by Nortel’s voicemail system Meridian Mail.

[84] No, you really don’t have to pay for this—and yes, it really does work.

[85] Also sometimes called a Message Transfer Agent.