terça-feira, agosto 28, 2012

Digium Free Fax For Asterisk and sendEmail - voip-info.org

Digium Free Fax For Asterisk and sendEmail - voip-info.org
register utility


This is a working example of a digium free fax for asterisk and fax to email implementation for asterisk .

Packages used

Digium Fax for Asterisk (receive faxes)
sendEmail (sending emails) - http://caspian.dotconf.net/menu/Software/SendEmail/


Create a Digium account and get a Free fax license key from digium store. Download fax modules(res_fax and res_fax_digium) and register utility from digium site. Extract them and copy the modules(.so files) to /usr/lib/asterisk/modules/. Register and make a license key by running register utility. After registration run " fax show licenses" from asterisk CLI to check the fax license. In this example I’m using fax detection for fax calls. So any fax calls on context voicemenu-custom-1 will be automatically detected and forwarded to fax-rx context. The received tiff file will be converted to pdf and sends as an attachment using sendEmail (perl script to send email)

Be sure to chown -R asterisk:asterisk /var/lib/asterisk or else asterisk can't "see" your newly registered license file.

Configuration files



exten = s,1,NoOp(ePillars_IVR)

exten = s,2,Answer()

exten = s,3,Wait(1)

exten = s,4,Background(IVR)

exten = 0,1,Goto(default,603,1)

exten = fax,1,Goto(fax-rx,receive,1)

exten => receive,1,NoOp(**** FAX RECEIVE ****)
exten => receive,n,Set(GLOBAL(FAXCOUNT)=$[${SHELL(ls -1 /var/www/html/fax/*.tif | wc -l)} +1])
exten => receive,n,Set(FAXCOUNT=${GLOBAL(FAXCOUNT)})
exten => receive,n,Set(FAXFILE=fax-${CALLERID(num)}-${FAXCOUNT}.tif)
exten => receive,n,Set(GLOBAL(LASTFAXCALLERNUM)=${CALLERID(num)})
exten => receive,n,Set(GLOBAL(LASTFAXCALLERNAME)=${CALLERID(name)})
exten => receive,n,NoOp(**** SETTING FAXOPT ****)
exten => receive,n,Set(FAXOPT(ecm)=yes)
exten => receive,n,Set(FAXOPT(headerinfo)=MY FAXBACK RX)
exten => receive,n,Set(FAXOPT(localstationid)=043263110)
exten => receive,n,Set(FAXOPT(maxrate)=14400)
exten => receive,n,Set(FAXOPT(minrate)=2400)
exten => receive,n,NoOp(FAXOPT(ecm) : ${FAXOPT(ecm)})
exten => receive,n,NoOp(FAXOPT(headerinfo) : ${FAXOPT(headerinfo)})
exten => receive,n,NoOp(FAXOPT(localstationid) : ${FAXOPT(localstationid)})
exten => receive,n,NoOp(FAXOPT(maxrate) : ${FAXOPT(maxrate)})
exten => receive,n,NoOp(FAXOPT(minrate) : ${FAXOPT(minrate)})
exten => receive,n,NoOp(**** RECEIVING FAX : ${FAXFILE} ****)
exten => receive,n,ReceiveFAX(/var/www/html/fax/${FAXFILE})
; Hangup! Print FAXOPTs
exten => h,1,NoOp(FAXOPT(ecm) : ${FAXOPT(ecm)})
exten => h,n,NoOp(FAXOPT(filename) : ${FAXOPT(filename)})
exten => h,n,NoOp(FAXOPT(headerinfo) : ${FAXOPT(headerinfo)})
exten => h,n,NoOp(FAXOPT(localstationid) : ${FAXOPT(localstationid)})
exten => h,n,NoOp(FAXOPT(maxrate) : ${FAXOPT(maxrate)})
exten => h,n,NoOp(FAXOPT(minrate) : ${FAXOPT(minrate)})
exten => h,n,NoOp(FAXOPT(pages) : ${FAXOPT(pages)})
exten => h,n,NoOp(FAXOPT(rate) : ${FAXOPT(rate)})
exten => h,n,NoOp(FAXOPT(remotestationid) : ${FAXOPT(remotestationid)})
exten => h,n,NoOp(FAXOPT(resolution) : ${FAXOPT(resolution)})
exten => h,n,NoOp(FAXOPT(status) : ${FAXOPT(status)})
exten => h,n,NoOp(FAXOPT(statusstr) : ${FAXOPT(statusstr)})
exten => h,n,NoOp(FAXOPT(error) : ${FAXOPT(error)})

exten => h,n,Set(PDFCNT=$[ ${SHELL(ls -1 /var/www/html/fax/*.pdf | wc -l)} +1])
exten => h,n,Set(FXN=${CALLERID(num)}-${PDFCNT})
exten => h,n,Set(FAXFILE=/var/www/html/fax/fax-${FXN}.pdf)
exten => h,n,Set(EXTEMAIL=touser@yourdomain.com)
exten => h,n,Set(EXTNAME=tousername)
exten => h,n,Set(EXTCOMPANY=comapny)
exten => h,n,System(tiff2pdf -o /var/www/html/fax/fax-${FXN}.pdf /var/www/html/fax/fax-${CALLERID(num)}-${FAXCOUNT}.tif)
exten => h,n,System(sleep 3)
exten => h,n,System(sendEmail -f user@yourdomain.com -t "${EXTNAME} <${EXTEMAIL}>" -u You have a FAX -a ${FAXFILE} -m You have a new FAX. Find attached. -s smtp.yourdomain.com -xu user@yourdomain.com -xp userpassword)

Download sendEmail script

Copy sendEmail.pl to the asterisk’s /usr/local/bin directory and give execute permission.

cp sendEmail.pl /usr/local/bin/sendEmail
chmod +x /usr/local/bin/sendEmail

By default all calls will be forwarded to fax receive context. Change according to your needs.,

For a custom FreePBX FAX configuration follow this.

Shyju Kanaprath(shyju at epillars dot com)

Nenhum comentário: