System information

We’re going to demonstrate how to connect to an IMAP-enabled Gmail account and
use that to store and retrieve our voicemail messages. If you haven’t already, read the
section “Enabling IMAP on your Gmail account” before proceeding. The final step is
configuring voicemail.conf to connect to the server.
In voicemail.conf, add the following lines to the [general] section. Be sure you only
specify a single format (we recommend wav49) for voicemail recordings, and remove
any references to ODBC voicemail storage if you’ve enabled that previously:
[general]
format=wav49 ; format to store files
imapserver=imap.gmail.com ; IMAP server location
imapport=993 ; port IMAP server listens to
imapflags=ssl ; flags required for connecting
expungeonhangup=yes ; delete messages on hangup
pollmailboxes=yes ; used for message waiting indication
pollfreq=30 ; how often to check for message changes
Before we configure our user for connecting to the Gmail IMAP server, let’s discuss the
options we’ve just set in the [general] section. These are the basic options that will get
us started; we’ll do some more customization shortly, but let’s see what we’ve done
so far.
First, the format=wav49 option has declared that we’re going to save our files as GSM
with a WAV header, which can be played on most desktops (including Microsoft Win-
dows) while retaining a small file size.
Next, we’ve configured Asterisk to connect to an imapserver located at
imap.gmail.com on imapport 993. We’ve also set imapflags to ssl, as Gmail requires a
secure connection. Without the ssl IMAP flag being set, the server will reject our con-
nection attempts (which is why it was important that we compiled our IMAP library
with OpenSSL support). Another option that may be required on private IMAP servers
such as Dovecot is to specify novalidate-cert for imapflags when an SSL connection
is necessary, but the certificate is not generated by a certificate authority.
Next, we’ve set expungeonhangup=yes, which causes messages marked for deletion to be
removed from the server upon hangup from the VoiceMail() application. Without this
option, messages are simply marked as read and left on the server until they have been
removed via an email application or web interface.
In order to get message waiting indication (MWI) updates correctly, we need to enable
pollmailboxes=yes, which causes Asterisk to check with the server for any changes to
the status of a message. For example, when someone leaves us a voicemail and we listen
to it by opening the message via our email application, the message will be marked as
read, but without polling the mailbox Asterisk will have no way of knowing this and
will enable the MWI light on the associated device indefinitely. Finally, we’ve set the
related option pollfreq to 30 seconds. This option controls how often Asterisk will ask
the server for the status of messages: set it appropriately to control the amount of traffic
going to the voicemail server.
416 | Chapter 18:External Services