Skip to content

How To: Asterisk Voicemail to Email Using Gmail Account

by Jon on December 28th, 2014

Updated 11-14-2015: Google made some changes to gmail account security so follow this link for an updated guide Asterisk Voicemail to Email Guide with Gmail

So my past post about using ssmtp to do voicemail to email with a Gmail account no longer works as some commenters pointed out. This sent me back to the drawing board to write an updated post to help all of you. This time I used postfix, included by default with CentOS installs making it easier.

Follow along below for your Asterisk voicemail to email with a Gmail account using the postfix application.

1. We do need to install a couple of extra packages even if postfix is already installed. I also am installing postfix just in case you didn’t have it installed.

yum -y install postfix mailx cyrus-sasl-plain

2. You need to create a new file with your Gmail account smtp server and credentials in the following format.

nano /etc/postfix/sasl_passwd

Paste in the below text and change the email address to your gmail email and enter in your password.

smtp.gmail.com    emailaddress@gmail.com:emailpassword

3. Once done doing that we want to hash your password file so it is not human readable.

 postmap hash:/etc/postfix/sasl_passwd

4. The next step is to configure postfix to use this new password file. Open the /etc/postfix/main.cf file using a text editor then scroll down to the bottom and paste in the following code.

nano /etc/postfix/main.cf
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
# Secure channel TLS with exact nexthop name match.
smtp_tls_security_level = secure
smtp_tls_mandatory_protocols = TLSv1
smtp_tls_mandatory_ciphers = high
smtp_tls_secure_cert_match = nexthop
smtp_tls_CAfile = /etc/pki/tls/certs/ca-bundle.crt
relayhost = smtp.gmail.com:587

postfix-asterisk-voicemail-email-gmail

5. Restart the postfix service.

service postfix restart

6. Now you can send a test email using the mail command in the following format.

mail email@website.com
Subject: Hello World
. (followed by enter key to send and exit)
EOT

asterisk-voicemail-email-gmail

7. Once you send that check your email to see if you received the email and as long as that is the case you can go ahead and remove the text password file.

rm /etc/postfix/sasl_passwd

8. Now you are all set, by default Asterisk will use the default mailing program so my voicemail.conf file looks like so.

[root@localhost ~]# cat /etc/asterisk/voicemail.conf
[general]
format = wav
serveremail = asterisk
attach = yes
skipms = 3000
maxsilence = 10
maxmessage = 300
review = yes
silencethreshold = 128
maxlogins = 3
emaildateformat = %A, %B %d, %Y at %r
sendvoicemail = yes
exitcontext = vm-operator
operator = yes
fromstring = PBX Voicemail

Hope you find this helpful and it works for you. Please let me know if there are any issues so I can correct my tutorial. I like my visitors to get their questions answered with a single visit, not having to bounce around from website to website trying to solve a problem.

Happy New Year! Onto 2015!

2 Comments
  1. Mike permalink

    Jon, I have followed your tutorial but unfortunately the mail is not working. The /var/log/maillog file states ” status=deferred (Cannot start TLS: handshake failure)
    Perhaps gmail requires different certificate since you originally wrote your tutorial?
    Thanks for any guidane you can give but please keep the instructions explicit (idiot proof).
    Regards
    Mike

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: