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'
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"
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
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/
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
to
<IfModule mod_alias.c>
ScriptAlias /cgi-bin/ /var/www/cgi-bin/
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

Comments
333DBI.pm
333Possible multi externnotify scripts?
Would I use something like:
externnotify=/usr/bin/index-mysql.pl, /usr/bin/chmod-vmail.sh
333A better solution?
333permissions permissions...
chown root:apache /var/spool/asterisk/voicemail/YOUR_CONTEXT/YOUR_MAILBOX
chmod 775 /var/spool/asterisk/voicemail/YOUR_CONTEXT/YOUR_MAILBOX
and have the following set in /etc/asterisk/voicemail.conf
externnotify=/usr/bin/voicemailapp.sh
and /usr/bin/voicemailapp.sh looks like:
#!/bin/sh
chmod 777 ` find /var/spool/asterisk/voicemail/ -name "*.txt" -o -name "*.wav"`
chmod 755 vmail.cgi (no need to suid). Delete and voicemail works for me. in the above chown command, make sure "apache" is replaced with the user that your web server runs with.
check this by putting $ then less than (stupid post wont use <) at the end of the copywrite (or a noticable chunk of text" and matching that user up with your distro's user file gentoo uses "apache"
333SELinux
333cron job for message permissions
This, of course, is pretty crude and will only suit home use (my current setup).
333Premature end of script headers
Add mysql to the list or prerequisites on this page.
333Modify Asterisk Source
You can do that after figuring out what the owner and group of the directory is or just chown the files to root:apache and chmod 660.
It can be a pain setting this up so it doesn't get screwed up. You have to make sure that the directories created for new mailboxes are 770 as well as 660 for any files, modifying the copy and file writing files in file.c and where they are called(the mode parameter) in app_voicemail.c.
Too bad the Asterisk devs don't have this built in or a configure option when compiling. Checking your voicemail from the web is very convenient.
333TheCara