Asterik faxt
Buch - Scripte

 

fax2mail

#!/bin/sh
#
#$1 ${CALLERIDNUM}
# $2 ${MAILADDRE}
# $3 ${FAXFILE}

#

echo Received paramters $1 $2 $3 >>/var/log/faxmail.log

MAILBODY=$3.txt
DATETIME=`date +"%A %d %b %Y %H:%M"`
PAGES=$(tiffinfo $3 | tail -21 |grep "Page" | cut -d "-" -f2)
DT=$(tiffinfo $3 | tail -21 |grep "Date" |cut -d "-" -f2)
DTFAX=${DT#*:}
COUNT=${PAGES#*-}
rm -f $MAILBODY
tiff2pdf $3 -o $3.pdf
echo >> $MAILBODY
echo ------------------------------------------------------------- >> $MAILBODY
echo Sie haben ein neues Fax bekommen. >> $MAILBODY
echo >> $MAILBODYecho Sendenummer: $1 >> $MAILBODY
echo Empfangszeit: $DTFAX >> $MAILBODY
echo Anzahl der Seiten: $COUNT >> $MAILBODY
echo >> $MAILBODY
echo Das Fax befindet sich im Anhang als PDF Datei. >> $MAILBODY
echo ------------------------------------------------------------- >> $MAILBODY
echo >> $MAILBODY
echo Thank you for using Open Source Software ! >> $MAILBODY
cat $3.txt | mail -r "Asterisk" -s "FAXEINGANG" -a "$3.pdf" $2
rm -f $MAILBODY

 

/etc/asterisk/extensions.conf

[macro-faxempfang]
exten => s,1,Set(SCRIPTFILE/usr/local/bin/fax2mail)
exten => s,n,Set(FAXFILE=/var/spool/asterisk/fax/${UNIQUEID})
exten => s,n,Set(MAILADDR=fax@domain)

[incoming_fax]
exten => 52,1,Wait(3)
exten => 52,n,Macro(faxempfang)
exten => 52,n,rxfax(${FAXFILE})
exten => 52,n,system("${SCRIPTFILE}" "${CALLERIDNUM}" "${MAILADDR}" "${FAXFILE}")
exten => 52,n,Hangup