How To: Configure Asterisk to Send Voicemail Email via Gmail SMTP Guide
12/28/2014 update: Since I had some commenters post about how this guide no longer worked I created a new guide using postfix to send voicemail to email with a Gmail account. I hope this helps all future visitors.
I created this guide to config asterisk to send voicemail’s via gmail since I didn’t find any complete guides out there. This is the quickest and easiest way to configure asterisk to email voicemail messages.
1. Uninstall sendmail and postfix if they are installed.
yum remove postfix Loaded plugins: fastestmirror, presto Setting up Remove Process Resolving Dependencies --> Running transaction check ---> Package postfix.x86_64 2:2.7.4-1.fc14 set to be erased ---> Package sendmail.x86_64 8.14.4-10.fc14 set to be erased --> Finished Dependency Resolution
2. Install Extra Packages for Enterprise Linux repository.
rpm -Uvh http://ftp.osuosl.org/pub/fedora-epel/5/i386/epel-release-5-4.noarch.rpm
3. Install ssmtp on the server.
yum -y install ssmtp Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package ssmtp.x86_64 0:2.61-15.fc14 set to be installed --> Finished Dependency Resolution
4. Backup the default ssmtp.conf file so we can create a new one with our gmail account.
cd /etc/ssmtp mv ssmtp.conf ssmtp.conf.org touch ssmtp.conf
5. Create a new config for ssmtp and add the gmail account to it by pasting in the below config and modify the email address and password.
# /etc/ssmtp/ssmtp.conf # ssmtp config for gmail or google apps account mailhub=smtp.gmail.com:587 firstname.lastname@example.org email@example.com AuthUserfirstname.lastname@example.org AuthPass=Enter-Password UseSTARTTLS=yes UseTLS=yes FromLineOverride=yes
6. Next you will need to add an entry for the root user to the revaliases file.
# /etc/ssmtp/revaliases # config for asterisk to email voicemail messages root:email@example.com:smtp.gmail.com:587
7. Now you can test sending a message from the command line.
[root@phone-call /]# ssmtp firstname.lastname@example.org To: email@example.com From: firstname.lastname@example.org Subject: Test Mail Connection The mail was sent from my Linux server [use CTRL + d to send email]
8. Asterisk needs to be configured to use ssmtp to email voicemails, to do this we are going to edit voicemail.conf in the asterisk directory.
; /etc/asterisk/voicemail.conf ; configure asterisk voicemail to use ssmtp to use a gmail account [general] format = wav attach = yes delete = yes maxmsg = 1000 envelope = yes skipms = 3000 maxsilence = 10 silencethreshold = 128 maxlogins = 3 emaildateformat = %A, %B %d, %Y at %r mailcmd=/usr/sbin/ssmtp -t fromstring=Phone Greetings VM pagerfromstring=Phone Greetings VM [default] 4400 => 123456,4400,email@example.com,firstname.lastname@example.org,attach=yes|delete=1 4401 => 123456,4401,email@example.com,firstname.lastname@example.org,,attach=yes
9. Just reload the voicemail config or restart asterisk and it will now email any new voicemail’s.
[root@phone-call /]# asterisk -r Asterisk 188.8.131.52, Copyright (C) 1999 - 2010 Digium, Inc. and others. Created by Mark Spencer Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details. This is free software, with components licensed under the GNU General Public License version 2 and other licenses; you are welcome to redistribute it under certain conditions. Type 'core show license' for details. ========================================================================= Connected to Asterisk 184.108.40.206 currently running on phone-call (pid = 10713) phone-call*CLI> module reload app_voicemail.so phone-call*CLI> exit [root@phone-call /]#
If you have any problems or a suggestion post a comment!
Update 09/26/2012: I just added a new post on how to play messages in your gmail account without downloading the wav file. Click here for the post.
Update 9/17/2014: Some users experienced an issue with the smtp server not responding due to a bug in the ssmtp app. If you get the following error:
ssmtp: Cannot open smtp.gmail.com:587
You will need to add the following line to your /etc/ssmtp/ssmtp.conf config file.
You can read about the bug here, https://bugzilla.redhat.com/show_bug.cgi?id=1004998.