Skip to content

How To: Configure Asterisk to Send Voicemail Email via Gmail SMTP Guide

by Jon on July 15th, 2011

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

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
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

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

7. Now you can test sending a message from the command line.

[root@phone-call /]# ssmtp
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
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

4400 => 123456,4400,,,attach=yes|delete=1
4401 => 123456,4401,,,,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, 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 currently running on phone-call (pid = 10713)
phone-call*CLI> module reload
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

You will need to add the following line to your /etc/ssmtp/ssmtp.conf config file.


You can read about the bug here,

From → Linux, VOIP

  1. wow… it’s great.. i never try to connect voice mail asterisk to mail from google …. actually i connected my asterisk voice mail to own mail server like zimbra … thanks for your post…

    • No problem, this is great because I know a lot of people who use google apps for their email hosting and this tutorial will work with gmail and google apps email addresses.

  2. gianni permalink

    Hello Friend,

    I have a problem, the email is send but only at the Pager Email Address and the email normal is not send. I have write in the box

    Email Address: My email
    Pager Email Address: My email

    The result i receive the pager email without file wav :-(

    I have trixbox System Status Version:

    Help me

    • I wrote this post to be used with an asterisk install from source. It should also work with trixbox but I couldn’t tell you why yours is not working, you might want to consult some tirxbox guides.

  3. Carl permalink

    I have an annoying problem. I followed the above instructions, and it did resolve my issue with Trixbox no longer emailing voicemails. For which I am grateful.
    My problem is, now I get every Cronjob and Logwatch message emailed to me as well. Any idea how to just disable the Cronjob and Logwatch emails from being sent? I get something like 5–7 a day. Thanks for you help!


    • Hi Carl,

      To stop the cron messages edit the crontab file with the following commands and add this entry to the top of the file mailto=””.

      This will open the crontab file in edit mode:

      crontab -e

      Depending on your distribution will determin what editor it will open in, most will open in VI, so press the “a” key to insert text, then type in mailto=”” and press the esc key. Now you are in the VI prompt, type wq and enter key which will write(save) and quit.

      Now you can double check your edit by using the following command:

      crontab -l

      Let me know if you have any questions.


  4. David permalink

    I have a problem with a attachment. When sombody of my users leaves a message to another user, in email only a text no attachments. How can fix this? any suggestions?

    • Hi David,

      If you want the voicemail attached on the email you will need to use the following settings in /etc/asterisk/voicemail.conf. In particular the code that attaches the wav file to the email is “attach=yes” make sure your voicemail.conf has that setting for all mailboxes. Only the first email address will get the attachement, the second email address is a pager address which will only send the text email.

      4400 => 123456,4400,,,attach=yes|delete=1
      4401 => 123456,4401,,,,attach=yes


  5. I love these article, im very happy

  6. jig1t permalink

    Thanks a lot!

  7. Joe permalink

    Brother, thank you so much! No other tutorial was able to get us operational, but yours was perfect.

  8. Ryan permalink

    I got the email + voicemail attachment to work, but now several users cannot call each other – it just goes straight to voicemail. Any ideas?

  9. Ryan permalink

    Also…Elastix no longer shows up.

  10. Raj permalink

    Hi jonathan,

    Great tutorial but i just want to check can i receive intrusion detection and other asterisk email notification with ssmtp? currently i’m using postfix for voicemail and for other asterisk notification, it worked but when i receive voicemail email it replace my email address name to Asterisk PBX.

    Can this change with ssmtp?
    And also can ssmtp work with other asterisk notification do i require any configuration for that? sorry for asking this kind of questions, I’m new for linux.

  11. Laurence Schenk permalink

    Thanks for the article.
    I had one problem with ssmtp: it produce the error:
    ssmtp: Cannot open

    I had to add the line:
    then every thing was happy.

    FYI if you get this error!


  12. Amir permalink

    Thanks for this post. I have a problem which is when I send an email it goes to spam folder. any suggestion?

  13. Brad permalink

    Thanks for the great article!

    I’m trying to set this up and am receiving an error I can’t seem to fix

    ssmtp: Authorization failed (535 5.7.8 jj6sm4838132igb.15 – gsmtp)

    I was receiving the error:
    ssmtp: Cannot open

    but fixed it by adding this to ssmtp.conf:

    Now the new error is showing up. Any idea how to fix this? I have tried changing passwords on my gmail account and following all the advice at the link in the error message with no luck.

  14. Andy permalink

    I also had the Authorization failed email, but solved it by doing this:

    1) Login to your gmail account.

    2) Go to and Turn On this feature.

    3) Go to and click Continue.

    Then you can authenticate your Additional Email Address from your Gmail Account.

    THX a lot everyone!

  15. Daian permalink

    Thanks, I just use your sample in Debian 8 SO and I have some issue with TLS certs, I just change the “hostname:smtp…” option to “hostname=localhost” and work’s like a charm 😉

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS

%d bloggers like this: