








E-MAIL NOTIFICATION ABOUT PROCESSED CALLS AND INCOMING VOICE MAIL ON ASTERISK
Configuring asterisk to e-mail notify about incoming calls and voicemailE-mail notification about processed calls and incoming voicemails on Asterisk PBX
Ubuntu 12.04+Asterisk+Sendmail
1. Goal:
1.1. E-mail notification about processed calls and incoming voicemails by using gmail.com account.
2. What we have (need):
2.1. Ubuntu 12.04 LTS Server;
2.2. Login and password from root account;
2.3. Installed Asterisk.
3. Resolving steps:
3.1.1. #apt-get install openssl
3.2. Installation Sendmail:
3.2.1. #apt-get install sendmail
3.3. certificate creating by OpenSSL:
3.3.1. creating directory for storing certificates: #mkdir /etc/mail/certs
3.3.2. changing folder rights for read, write, execute. #chmod 700 /etc/mail/certs
3.3.3. getting to the directory #cd /etc/mail/certs
3.3.4. Certificate genereating #openssl dsaparam 1024 -out dsa1024 -out dsa1024.pem
3.3.5. #openssl req -x509 -nodes -days 3650 -newkey dsa:dsa1024.pem -out /etc/mail/certs/mycert.pem -keyout /etc/mail/certs/mykey.pem
3.3.6. #openssl req -x509 -new -days 3650 -key /etc/mail/certs/mykey.pem -out /etc/mail/certs/mycert.pem
3.3.7. creating link #ln -s /etc/mail/certs/mycert.pem /etc/mail/certs/CAcert.pem
3.3.8. changing rights #chmod 600 /etc/mail/certs/*
3.4. Sendmail configs preparation:
3.4.1. Making directory #mkdir /etc/mail/auth
3.4.2. making file: #nano /etc/mail/auth/authinfo
3.4.3. entering to this file following info:
AuthInfo:smtp.gmail.com:587 "U:root" "I:USERNAME@gmail.com" "P:PASSWORD" "M:PLAIN"
AuthInfo: "U:root" "I:USERNAME@gmail.com" "P:PASSWORD" "M:PLAIN"
Where USERNAME@gmail.com – gmail.com account.
PASSWORD – password from gmail.com account.
3.4.4. Copying this file:
makemap hash -r /etc/mail/auth/authinfo < /etc/mail/auth/authinfo
3.4.5. Adding configs to the /etc/mail/sendmail.mc. (should be added before the first FEATURE)
#nano /etc/mail/sendmail.mc
dnl # Smrp relay
define(`CERT_DIR', `MAIL_SETTINGS_DIR`'certs')
define(`confCACERT_PATH', `CERT_DIR')
define(`confCACERT', `CERT_DIR/CAcert.pem')
define(`confSERVER_CERT', `CERT_DIR/mycert.pem')
define(`confSERVER_KEY', `CERT_DIR/mykey.pem')
define(`confCLIENT_CERT', `CERT_DIR/mycert.pem')
define(`confCLIENT_KEY', `CERT_DIR/mykey.pem')
dnl #
dnl # gmail auth
define(`SMART_HOST',`[smtp.gmail.com]')dnl
define(`RELAY_MAILER_ARGS', `TCP $h 587')dnl
define(`ESMTP_MAILER_ARGS', `TCP $h 587')dnl
define(`confAUTH_OPTIONS', `A p')dnl
TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
FEATURE(`authinfo',`hash -o /etc/mail/auth/authinfo.db')dnl
3.4.6. Compiling config:
make -C /etc/mail
3.5. Creating shell script which will e-mail notify about incoming call and voice mail;
undefined">3.5.1. Creating shell script #nano /var/lib/asterisk/agi-bin/processEmail.sh
3.5.2. it should content the following:
processEmail.sh
where your_sending@email.net – e-mail address from which we want to send.
3.5.3. Changing shell script rights for execution, reading and writing:
#chmod 755 /var/lib/asterisk/agi-bin/processEmail.sh
3.6. Configuring asterisk to send e-mail notification about processed call.
#nano /etc/asterisk/extensions.conf
Add at the end of extension which incoming call should e-mail notified:
exten => h,1,System(/var/lib/asterisk/agi-bin/processEmail.sh "my@email.net" "${CALLERID(num)}" "${CALLERID(name)}" "${DIALSTATUS}" "${VMSTATUS}" "${EXTEN}")
Where my@email.net – e-mail address taht should be notified about incoming call.
3.7. Restarting serices:
#service sendmail restart