On Monday 15 May 2006 03:38, Reza - Asterisk Enthusiast wrote:
> Has anyone integrated Fax services with Asterisk?   That is receiving
> incoming faxes & e-mailing it.  And also sending the file (in word or PDF
> format) to an e-mail address and Asterisk processing it & sending it to the
> appropriate destination.    If so, please share your experience as I would
> like to get something similar set up at my end.

Yep, it isn't difficult, provided that you do not get tripped up with a bum 
version of libtiff.  There are several versions of libtiff that do an 
absolutely hideous job at handling fax-format TIFF files (creating or reading 
them).  If you do not totally rid your system of any existing libtiff and its 
headers then there will be much wailing and gnashing of teeth.

Do not trust your package manager.  Even the ineffable Slackware, my distro of 
choice, throws a curve when it comes to libtiff.

At any rate, once that is done and you install a pristine version of libtiff 
that has been blessed by coppice[1] himself, the procedure is as follows, at 
least for me:

- install libtiff
- install spandsp
- grab the app_rxfax and app_txfax apps from the spandsp directory and install 
them
- the following dialplan:
===========8<=================
exten => 5551212,1,Set(FAXFILE=/var/spool/asterisk/faxin/${UNIQUEID}.tiff)
exten => 5551212,n,Set(LOCALSTATIONID=519 555 1212)
exten => 5551212,n,Set(LOCALHEADERINFO=519 555 1212)
exten => 5551212,n,RxFax(${FAXFILE})
exten => 5551212,n,Hangup

exten => h,1,NoOp(REMOTESTATIONID is ${REMOTESTATIONID})
exten => h,n,NoOp(FAXPAGES is ${FAXPAGES})
exten => h,n,NoOp(FAXBITRATE is ${FAXBITRATE})
exten => h,n,NoOp(FAXRESOLUTION is ${FAXRESOLUTION})
exten => h,n,System(/usr/local/scripts/processfax.sh ${FAXFILE} [EMAIL 
PROTECTED] 
"${CALLERIDNUM} ${CALLERIDNAME}")
===========8<=================

And the following script:
===========8<=================
#!/bin/sh

FAXFILE=$1
RECIPIENT=$2
FAXSENDER=$3

PDF=`/usr/bin/basename $1 .tiff`.pdf

# only attempt to process the fax if the filesize is > 0 bytes
if [ -s $FAXFILE ]; then
        /usr/local/bin/tiff2ps -2eaz -w 8.5 -h 11 $FAXFILE | /usr/bin/ps2pdf - 
> /tmp/$PDF

# uncomment this to make an email of it, but I just scp it to my home server.
#/usr/bin/mime-construct --to $RECIPIENT --subject "Fax from $FAXSENDER" \
#  --attachment $PDF --type application/pdf --file /tmp/$PDF

        /usr/bin/scp -P 2200 -i ~/.ssh/faxes.dsa /tmp/$PDF 
[EMAIL PROTECTED]:/mnt/work/faxes/
        /usr/bin/ssh -p 2200 -i ~/.ssh/faxes.dsa [EMAIL PROTECTED] "chmod 
666 /mnt/work/faxes/*.pdf"
else
        echo "Ignoring 0-length fax file"
fi

rm -f /tmp/$PDF
===========8<=================

Pretty simple and straightforward, eh?  You can trap the 'fax' extension too 
if you're using a zaptel channel and have that functionality enabled, but I 
was never keen on that.

-A.

[1] - Coppice (Steven Underwood) is the author of spandsp, and one hell of a 
smart man. I am POSITIVE that this guy does not count sheep to fall asleep 
but rather computes a statistical analysis in his head of white noise in the 
room to ensure it has a truly uniform energy distribution.

Reply via email to