Here is how you can make asterisk use GMAIL to send voicemails
1> Login to Gmail Account
2> Set "Less secure app access" to ON.
http://www.google.com/settings/security/lesssecureapps
3> Install POSTFIX
yum -y install postfix mailx cyrus-sasl-plain
4> Edit password file. Use VI or NANO (nano instructions below)
vi /etc/postfix/sasl_passwd
or
nano /etc/postfix/sasl_passwd
If you aren't familiar with Vi, you can install NANO using the following command
yum install nano
Use your gmail credentials. This file will be encrypted and deleted after you confirm successful test
smtp.gmail.com GMailUserName@gmail.com:GMailPassword
5> Encrypt the gmail authentication
postmap hash:/etc/postfix/sasl_passwd
6> Edit the postfix config file /etc/postfix/main.cf
Paste the information below and save
smtp_sasl_auth_enable = yes
relayhost = smtp.gmail.com:587
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
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
7> Reload the mail service
service postfix restart
8> Send a test message
[root@issabel asterisk]# mail SomeEmailAccount@domain.com
Subject: This is an email test
This is a test.
.
(the "." by itself will send the message)
If everything worked, you will get the email.
If NO email showed up, you can look at the mail log /var/log/maillog to help troubleshoot
This is an example of a successful message emailed through GMAIL
Sep 2 1:20:45 issabel postfix/pickup[50041]: AAD341428DC: uid=0 from=<root>
Sep 2 1:20:45 issabel postfix/cleanup[50295]: AAD341428DC: message-id=<20191129142045.AAD341428DC@issabel.local>
Sep 2 1:20:45 issabel postfix/qmgr[50042]: AAD341428DC: from=<root@issabel.local>, size=427, nrcpt=1 (queue active)
Sep 2 1:20:45 issabel postfix/smtp[50297]: connect to smtp.gmail.com[2607:f8b0:400d:c0e::6c]:587: Network is unreachable
Sep 2 1:20:47 issabel postfix/smtp[50297]: AAD341428DC: to=<SomeEmailAccount@domain.com>, relay=smtp.gmail.com[209.85.144.109]:587, delay=1.9, delays=0.05/0.04/1/0.74, dsn=2.0.0, status=sent (250 2.0.0 OK 1575037247 o70sm10311267qke.47 - gsmtp)
Sep 2 1:20:47 issabel postfix/qmgr[50042]: AAD341428DC: removed
9> Delete the original gmail password file (it is now stored and encrypted in POSTFIX)
rm /etc/postfix/sasl_passwd
10> Set email addresses to your voicemail accounts in the PBX GUI.