Asterisk gui vmail.cgi

Web interface to Voicemail

There is a perl script included in the source distribution, vmail.cgi, located in

/usr/src/asterisk/contrib/scripts/vmail.cgi

Note that 'make install' doesn't install this interface, instead you must run 'make webvmail' separatly.
The vmail.cgi script requires that perl, perl-suidperl and libdbi-perl packages be installed and of course a web server.

rpm -q perl perl-suidperl httpd

On CentOS 5 you can just do 'yum install perl-suidperl'

This script may require some editing to get it working on your installation.
/usr/src/asterisk/images/*.gif copied to /_asterisk in the html tree
(or edit $astpath)

Also the CGI script needs to be made executable:

chmod +x vmail.cgi

On RedHat, perl-suidperl doesn't exist. Instead /var/spool/asterisk/voicemail/ files need to be made world-readable (or group-readable & group set to whatever httpd runs at - e.g. 'apache'). Apparently a patch exists to fix permissions as files are created:
http://lists.digium.com/pipermail/asterisk-users/2003-May/011845.html
http://lists.digium.com/pipermail/asterisk-dev/2003-June/000953.html

On Fedora Core 3 you may need to disable SELinux to allow vmail.cgi access to your /var/spool/asterisk directory

After you get the script installed, you access it with http://yourserver/cgi-bin/vmail.cgi

An updated version of this script and PHP versions are forthcoming.

On Gentoo you will most probably have to take these additional steps in order to get a fully working vmail.cgi:
  • perl -MCPAN -e 'install Bundle::DBI'
  • perl -MCPAN -e 'install DBD::mysql'
Note thet DBD::mysql can be nasty to install since it wants to run all kind of weird tests on a mysql database called 'test' requiring an empty root password...! You can circumenvent this issue by manually downloading DBD::mysql as tar.gz file from www.cpan.org, then running 'Makefile.PL' followed by 'make' and 'make install'.

Desember 1,2011 -

In Fedora/Redhat or similar it would be yum install perl-CGI-Session.
In Debian-based, apt-get install libcgi-session-perl .

April 13, 2011 - Red Hat Enterprise Linux (CentOS should be identical) - Web Voicemail Interface installation:


1. Install Apache:
  1. yum install httpd

2. Start Apache:
  1. service httpd start

3. To start Apache at boot automatically:
  1. chkconfig httpd on

4. Compile webvmail form the /usr/src/asterisk directory:
  1. make webvmail

5. Install webvmail:
  1. make install webvmail

6. Perl needed to run above:
  1. yum install perl-suidperl

7. DBI needed for Perl:
  1. perl -MCPAN -e 'install DBI'

8. To allow the Web Voicemail Interface to "turn off" MWI on the phone set, once you delete a message: Edit /etc/asterisk/voicemail.conf and set "pollmailboxes=yes".

Now you should be able to browse to the Web Voicemail Interface:
http://<server address>/cgi-bin/vmail.cgi



Nov 10, 2004: Asterisk-Users mailing list


"Attached is a patch I made to app_voicemail.c that will set the owner, group and perms of all files and directories that are created so that vmail.cgi can run as user/group apache without setuid on vmail.cgi. The owner/group/perms are configurable in some static variables at the top so if you need them to change, you only need to change them there. Hope this helps.

Adam Fineberg"


Link to patch

I was getting a broken pipe error when leaving a voicemail with this patch. My problem was that there was no apache group on the box I was saving voicemail to, so I changed the group to root and gave read/write to all by changing the following lines:

static char *gname = "root";
static mode_t dirMode = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH;
static mode_t filMode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;

Adding the bold parts. A more secure way is to actually add the apache group (manually or by installing apache). Hope this helps anyone who spent weeks trying to figure out the broken pipe error. - flobi


Nov 21, 2005: The above patch by Adam Fineberg is not working any more on current CVS, so i manually patched app_voicemail.c. The hints of flobi still apply. - bladerunner


Patch against CVS Nov 21, 2005


Using webvmail on debian 3.1 (sarge)

See also this posting and that posting on asterisk-users.

You need to have the following debian packages installed
  • apache (the following does not apply to apache2!)
  • perl
  • perl-suid

The default apache /etc/apache/httpd.conf that the debian apache package installs needs to be changed as follows:

at line 556 change
<IfModule mod_alias.c>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

to
<IfModule mod_alias.c>
ScriptAlias /cgi-bin/ /var/www/cgi-bin/


at line 562 change
<Directory /usr/lib/cgi-bin/>

to
<Directory /var/www/cgi-bin/>


now restart apache
/etc/init.d/apache restart

in /var/www make sure you have a cgi-bin folder and a html folder in /var/www. If not
cd /var/www mkdir cgi-bin html

now in your asterisk source directory (/usr/src/asterisk) type
make webvmail

now edit the cgi file /var/www/cgi-bin/vmail.cgi with your favorite text editor
edit line 18 "$context=""; # Define here your by default context (so you don't need to put voicemail@context in the login" as needed and save.

go to http://your.ip.address/cgi-bin/vmail.cgi and login (:wink:)

The externnotify approach

In order for a user to have access to their voicemail, something must be done to the files in /var/spool/asterisk/voicemail/. I added the command "chmod -R a+rw /var/spool/asterisk/voicemail/default/" in a script that is called whenever a voicemail is left. That script is referenced in voicemail.conf as "externnotify=". This will allow anyone to read/write the voicemail files. No one has a login to my asterisk server so I don't care. You might want to set up a group or something.

vmail.cgi, AsteriskGUI, and users.conf

The current version of vmail.cgi (part of 1.4.21.2) only looks in the voicemail.conf file for information on voicemailboxes. The AsteriskGUI, however, also puts voicemail configuration information in the users.conf file. The result is that vmail.cgi does not currently provide access to the voicemail of users defined through the AsteriskGUI.


See also

  • Asterisk voicemail: Overview
  • Asterisk gui tycho: "Tycho" Ecllipse based Voicemail Client and Dial-Assistant
  • ARI: Asterisk Recording Interface (for Monitor() and Voicemail)
  • Asterisk Realtime Voicemail: Store voicemail in a database (Asterisk 1.2)
  • Asterisk GUI: Graphical user interfaces to Asterisk, especially look at ARI there
  • voicemail-20050331.patch
  • bug/patch 6334: Solving the access right problem for voicemail files, included in Asterisk 1.4.0
  • bug/patch 5929: Modifies group permissions for voicemail files, included in Asterisk 1.2.5

Web interface to Voicemail

There is a perl script included in the source distribution, vmail.cgi, located in

/usr/src/asterisk/contrib/scripts/vmail.cgi

Note that 'make install' doesn't install this interface, instead you must run 'make webvmail' separatly.
The vmail.cgi script requires that perl, perl-suidperl and libdbi-perl packages be installed and of course a web server.

rpm -q perl perl-suidperl httpd

On CentOS 5 you can just do 'yum install perl-suidperl'

This script may require some editing to get it working on your installation.
/usr/src/asterisk/images/*.gif copied to /_asterisk in the html tree
(or edit $astpath)

Also the CGI script needs to be made executable:

chmod +x vmail.cgi

On RedHat, perl-suidperl doesn't exist. Instead /var/spool/asterisk/voicemail/ files need to be made world-readable (or group-readable & group set to whatever httpd runs at - e.g. 'apache'). Apparently a patch exists to fix permissions as files are created:
http://lists.digium.com/pipermail/asterisk-users/2003-May/011845.html
http://lists.digium.com/pipermail/asterisk-dev/2003-June/000953.html

On Fedora Core 3 you may need to disable SELinux to allow vmail.cgi access to your /var/spool/asterisk directory

After you get the script installed, you access it with http://yourserver/cgi-bin/vmail.cgi

An updated version of this script and PHP versions are forthcoming.

On Gentoo you will most probably have to take these additional steps in order to get a fully working vmail.cgi:
  • perl -MCPAN -e 'install Bundle::DBI'
  • perl -MCPAN -e 'install DBD::mysql'
Note thet DBD::mysql can be nasty to install since it wants to run all kind of weird tests on a mysql database called 'test' requiring an empty root password...! You can circumenvent this issue by manually downloading DBD::mysql as tar.gz file from www.cpan.org, then running 'Makefile.PL' followed by 'make' and 'make install'.

Desember 1,2011 -

In Fedora/Redhat or similar it would be yum install perl-CGI-Session.
In Debian-based, apt-get install libcgi-session-perl .

April 13, 2011 - Red Hat Enterprise Linux (CentOS should be identical) - Web Voicemail Interface installation:


1. Install Apache:
  1. yum install httpd

2. Start Apache:
  1. service httpd start

3. To start Apache at boot automatically:
  1. chkconfig httpd on

4. Compile webvmail form the /usr/src/asterisk directory:
  1. make webvmail

5. Install webvmail:
  1. make install webvmail

6. Perl needed to run above:
  1. yum install perl-suidperl

7. DBI needed for Perl:
  1. perl -MCPAN -e 'install DBI'

8. To allow the Web Voicemail Interface to "turn off" MWI on the phone set, once you delete a message: Edit /etc/asterisk/voicemail.conf and set "pollmailboxes=yes".

Now you should be able to browse to the Web Voicemail Interface:
http://<server address>/cgi-bin/vmail.cgi



Nov 10, 2004: Asterisk-Users mailing list


"Attached is a patch I made to app_voicemail.c that will set the owner, group and perms of all files and directories that are created so that vmail.cgi can run as user/group apache without setuid on vmail.cgi. The owner/group/perms are configurable in some static variables at the top so if you need them to change, you only need to change them there. Hope this helps.

Adam Fineberg"


Link to patch

I was getting a broken pipe error when leaving a voicemail with this patch. My problem was that there was no apache group on the box I was saving voicemail to, so I changed the group to root and gave read/write to all by changing the following lines:

static char *gname = "root";
static mode_t dirMode = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH;
static mode_t filMode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;

Adding the bold parts. A more secure way is to actually add the apache group (manually or by installing apache). Hope this helps anyone who spent weeks trying to figure out the broken pipe error. - flobi


Nov 21, 2005: The above patch by Adam Fineberg is not working any more on current CVS, so i manually patched app_voicemail.c. The hints of flobi still apply. - bladerunner


Patch against CVS Nov 21, 2005


Using webvmail on debian 3.1 (sarge)

See also this posting and that posting on asterisk-users.

You need to have the following debian packages installed
  • apache (the following does not apply to apache2!)
  • perl
  • perl-suid

The default apache /etc/apache/httpd.conf that the debian apache package installs needs to be changed as follows:

at line 556 change
<IfModule mod_alias.c>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

to
<IfModule mod_alias.c>
ScriptAlias /cgi-bin/ /var/www/cgi-bin/


at line 562 change
<Directory /usr/lib/cgi-bin/>

to
<Directory /var/www/cgi-bin/>


now restart apache
/etc/init.d/apache restart

in /var/www make sure you have a cgi-bin folder and a html folder in /var/www. If not
cd /var/www mkdir cgi-bin html

now in your asterisk source directory (/usr/src/asterisk) type
make webvmail

now edit the cgi file /var/www/cgi-bin/vmail.cgi with your favorite text editor
edit line 18 "$context=""; # Define here your by default context (so you don't need to put voicemail@context in the login" as needed and save.

go to http://your.ip.address/cgi-bin/vmail.cgi and login (:wink:)

The externnotify approach

In order for a user to have access to their voicemail, something must be done to the files in /var/spool/asterisk/voicemail/. I added the command "chmod -R a+rw /var/spool/asterisk/voicemail/default/" in a script that is called whenever a voicemail is left. That script is referenced in voicemail.conf as "externnotify=". This will allow anyone to read/write the voicemail files. No one has a login to my asterisk server so I don't care. You might want to set up a group or something.

vmail.cgi, AsteriskGUI, and users.conf

The current version of vmail.cgi (part of 1.4.21.2) only looks in the voicemail.conf file for information on voicemailboxes. The AsteriskGUI, however, also puts voicemail configuration information in the users.conf file. The result is that vmail.cgi does not currently provide access to the voicemail of users defined through the AsteriskGUI.


See also

  • Asterisk voicemail: Overview
  • Asterisk gui tycho: "Tycho" Ecllipse based Voicemail Client and Dial-Assistant
  • ARI: Asterisk Recording Interface (for Monitor() and Voicemail)
  • Asterisk Realtime Voicemail: Store voicemail in a database (Asterisk 1.2)
  • Asterisk GUI: Graphical user interfaces to Asterisk, especially look at ARI there
  • voicemail-20050331.patch
  • bug/patch 6334: Solving the access right problem for voicemail files, included in Asterisk 1.4.0
  • bug/patch 5929: Modifies group permissions for voicemail files, included in Asterisk 1.2.5

Created by: oej, Last modification: Thu 01 of Dec, 2011 (13:58 UTC) by andrey1969
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+