Configuring Asterisk for Receiving FAX to Email Based on article http://www.voip-info.org/wiki/view/Asterisk+Fax+to+email? This installation was done using 64 bit CentOS 5.4 and Asterisk 1.6.0.25. Spandsp Spandsp must be installed to provide FAX functions for Asterisk. Spandsp version 0.0.5 was used and configured with –prefix=/usr. The app_fax application becomes available to the Asterisk’s menuconfig once spandsp is installed. Spandsp can be obtained from here. http://www.soft-switch.org/downloads/spandsp/ Chan_Dahdi.conf I enabled the following. This is all that is required on the dahdi side of things. Once a fax is detected on the incoming channel, the call will be redirected automagically to exten’s defined by fax within the same context (at least, this is my understanding). This can be seen in example 2.2. Example 1.1 Faxdetect=incoming Extensions.conf I created a new context called faxreceive as follows. You probably will need to create the folder /var/spool/asterisk/fax also. Example 2.1 [faxreceive] exten => s,1,Set(FAXFILE=/var/spool/asterisk/fax/${CALLEDFAX}/${UNIQUEID}) exten => s,2,Set(EXTMAIL=fax@email.address) exten => s,3,Set(EXTNAME=Unknown) exten => s,4,ReceiveFAX(${FAXFILE}.tif) exten = s,5,NoOP(/var/lib/asterisk/scripts/mailfax "${CALLERID(num)}" "${CALLEDFAX}" "${EXTNAME}" "${EXTMAIL}" "${FAXFILE}" "${EXTCOMPANY}") exten = s,6,System(/var/lib/asterisk/scripts/mailfax "${CALLERID(num)}" "${CALLEDFAX}" "${EXTNAME}" "${EXTMAIL}" "${FAXFILE}" "${EXTCOMPANY}") I added the following to the end of [default] context. Example 2.2 exten = fax,1,Gosub(faxreceive,s,1) mailfax Script My mailfax script that I created in /var/lib/asterisk/scripts is as follows. Example 3.1 #!/bin/bash echo Received paramters $1 $2 $3 $4 $5 $6 >>/var/log/faxmail.log DATETIME=`date +"%A %d %b %Y %H:%M"` if [ -e $5.tif ] then echo fax file $5.tif found. Sending email to $4 .... >>/var/log/faxmail.log PAGES=$(tiffinfo $5.tif | grep "Page") DT=$(tiffinfo $5.tif | grep "Date") DTFAX=${DT#*:} COUNT=${PAGES#*-} rm -f $5.txt echo Dear $3, >>$5.txt echo >>$5.txt echo You have just received a new fax document. Details as follow >>$5.txt echo >>$5.txt echo "From : "$1 >>$5.txt echo "To : "$2 >>$5.txt echo "When : "$DATETIME '['$DTFAX' ]'>>$5.txt echo "Pages : "$COUNT>>$5.txt echo >>$5.txt echo >>$5.txt echo Thank you for using less paper. echo sendEmail -f fax@email.address -t $4 -u "New fax received" -a $5.tif -o message-file=$5.txt \ >> /var/log/faxmail.log echo "<<<<<<<<<<<<<<<<<<<<---------------->>>>>>>>>>>>>>>>>>>>>>>>>" >> /var/log/faxmail.log /usr/local/bin/sendEmail -l /var/log/sendEmail.log -f fax@email.address -t $4 -u "New fax received" -a $5.tif -o "message-file=$5.txt" else rm -f $5.txt echo Dear $3, >>$5.txt echo >>$5.txt echo A call was received on your fax line, however no fax was received or the attempt failed. Details as follow >>$5.txt echo >>$5.txt echo "From : "$1 >>$5.txt echo "To : "$2 >>$5.txt #echo $DATETIME >>$5.txt echo "When : "$DATETIME >>$5.txt #echo "Pages : "$COUNT>>$5.txt echo >>$5.txt echo >>$5.txt echo Thank you for using less paper. echo sendEmail -f fax@email.address -t $4 -u "Fax reception failed" -o message-file=$5.txt \ >> /var/log/faxmail.log echo "<<<<<<<<<<<<<<<<<<<<---------------->>>>>>>>>>>>>>>>>>>>>>>>>" >> /var/log/faxmail.log /usr/local/bin/sendEmail -l /var/log/sendEmail.log -f $fax@email.address -t $4 -u "Fax reception failed" -o "message-file=$5.txt" exit fi sendEmail, which is referenced in the above script, can be obtained from: http://caspian.dotconf.net/menu/Software/SendEmail/ After installing spandsp and enabling faxdetect, I found it was necessary to run the following from shell before running asterisk in order to prevent asterisk from crashing while receiving a fax. I suspect (although I do not know for sure) this may be due to 64 bit compiling. Example 3.2 export MALLOC_CHECK_=0