FAX to Email [Asterisk] . T.38
Hi all
I always like to get involved new / challenging project. I got one . One of my client likes to have FAX to Email service at a very minimum cost.
Project: Install FAX to Email service using 100% freeware and open source Platform.
Same as before: I tried Google and found quit lot information. But none of them [I found] gave me total step by step solution.
I like to share my experience and solution with everyone.
Target :
FAX to Email service.
Software and Hardware I used:
OS: CentOS release 6.2 [64bit] .
Server: Dell R510.
Asterisk version: Asterisk 10.4.0
Some tools need to make tiff to pdf and send email using smtp :
*. yum install poppler-utils.x86_64
*. Download sendEmail-v1.56.tar.gz and setup . very easy just read the README .
Setup:
1. Install the Asterisk : you could do that or you don’t need to do FAXing.
2. Go to http://store.digium.com/products.php?category_id=94 buy [FREE or Paid. I use FREE] Fax for Asterisk License. After purchase they will email you the license key.
3. Go to http://downloads.digium.com/pub/register/ download the register file. I used x86-64.
4. Chmod +x register
5. ./ register and it will ask you for KEY. Follow the steps.
6. Go to http://www.digium.com/en/docs/FAX/faa-download.php. Download the files what matches your system .
I used 64bit and Flavor: Core 2 [http://downloads.digium.com/pub/telephony/fax/res_fax_digium/asterisk-10.1/x86-64/res_fax_digium-10.1_1.3.0-core2_64.tar.gz]
7. untar the file and copy res_fax_digium.so to /usr/lib/asterisk/modules/ and res_fax_digium.conf to /etc/asterisk
8. Reboot your system
Verify the setting: bellow is my running system log.
asterisk –r
did*CLI> fax show stats
FAX Statistics:
---------------
Current Sessions : 0
Reserved Sessions : 0
Transmit Attempts : 0
Receive Attempts : 9
Completed FAXes : 9
Failed FAXes : 2
Digium G.711
Licensed Channels : 1
Max Concurrent : 1
Success : 7
Switched to T.38 : 0
Canceled : 0
No FAX : 0
Partial : 1
Negotiation Failed : 0
Train Failure : 1
Protocol Error : 0
IO Partial : 0
IO Fail : 0
Digium T.38
Licensed Channels : 1
Max Concurrent : 0
Success : 0
Canceled : 0
No FAX : 0
Partial : 0
Negotiation Failed : 0
Train Failure : 0
Protocol Error : 0
IO Partial : 0
IO Fail : 0
did*CLI> fax show settings
FAX For Asterisk Settings:
ECM: Enabled
Status Events: On
Minimum Bit Rate: 2400
Maximum Bit Rate: 14400
Modem Modulations Allowed: V17,V27,V29
FAX Technology Modules:
DIGIUM (Digium FAX Driver) Settings:
Maximum T.38 Packet Delay: 800
T.38 Session Packet Capture: Off
G.711 Session Audio Capture: Off
did*CLI> fax show licenses
Fax Licensing Information
==============================
Free fax licenses: 1
Total licensed ports: 1
Licenses Found:
File: FFA-XXXXXXXXXXX.lic -- Key: FFA-XXXXXXXXXXXXX -- Product: XXXXXXXX -- Host-ID: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -- Ports: 1 (OK)
did*CLI> fax show version
FAX For Asterisk Components:
Applications: 10.4.0
Digium FAX Driver: 10.1_1.3.0 (optimized for core2_64)
did*CLI> fax show capabilities
Registered FAX Technology Modules:
Type : DIGIUM
Description : Digium FAX Driver
Capabilities : SEND RECEIVE T.38 G.711 MULTI-DOC
1 registered modules
Now: Extension and Context:
Sip.conf :
[general]
XXXXX
t38pt_udptl = yes
allow=all
allowguest=no
XXXXX
; provider
[My provider]
type=peer
insecure=port,invite
host=1.1.1.1
canreinvite=no
allow=all
qualify=no
nat=yes
dtmfmode=rfc2833
t38pt_udptl=no
exentsion.conf
[macro-startfax]
exten => s,1,Set(FAXOPT(ecm)=yes)
exten => s,n,Set(FAXOPT(maxrate)=14400)
exten => s,n,Set(FAXOPT(minrate)=2400)
exten => s,n,NoOp(FAXOPT(ecm) : ${FAXOPT(ecm)})
exten => s,n,Set(EXTEMAIL=a@s.com)
exten => s,n,Set(EXTNAME=VACL)
exten => s,n,Set(EXTCOMPANY=SNFax www.snfax.com)
exten => s,n,Set(FAXFILE=/var/spool/asterisk/fax/${CALLEDFAX}/${UNIQUEID})
exten => s,n,ReceiveFAX(${FAXFILE}.tif)
exten => s,n,Hangup
[fax]
exten => xxx,1,Macro(startfax)
exten =>xxx,n,Hangup
exten => h,1,System(/var/lib/asterisk/scripts/mailfax "${CALLERID(num)}" "${CALLEDFAX}" "${EXTNAME}" "${EXTEMAIL}" "${FAXFILE}" "${EXTCOMPANY}" "${CALLERID(name)}")
;Debuging log
exten => h,n,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(error) : ${FAXOPT(error)})
[default]
;FAX extension
exten => xxx,1,Wait(2)
exten => xxx,n,Ringing()
exten => xxx,n,Set(CALLEDFAX=${EXTEN})
exten => xx,n,Goto(fax,${EXTEN},1)
;End Fax setting
Script : I found it from google and did some modification :
echo Received paramters $1 $2 $3 $4 $5 $6 $7 >>/var/log/faxmail.log
DATETIME=`date +"%A %d %b %Y %H:%M"`
if [ -e $5.tif ]
then
/usr/bin/tiff2pdf -p A4 $5.tif -o $5.pdf
echo fax file $5.pdf found. Sending email to $4 .... >>/var/log/faxmail.log
PAGES=$(pdfinfo $5.pdf | grep "Pages")
DT=$(pdfinfo $5.pdf | grep "ModDate")
DTFAX=${DT#*:}
COUNT=${PAGES#*-}
rm -f $5.txt
echo Dear $3, >>$5.txt
echo >>$5.txt
echo You have just recieved a new fax document. Details as follow >>$5.txt
echo >>$5.txt
echo "From : "$1 >>$5.txt
echo "To : "$2 >>$5.txt
echo "Date Time : "$DATETIME " Eastern Daylight Time [EDT,New York]">>$5.txt
echo "Number of "$COUNT>>$5.txt
echo >>$5.txt
echo >>$5.txt
echo Thank you for using $6 >>$5.txt
echo sendEmail -f fax@vacl.us -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 -s d.com -xu d@d.com -xp aaa -f fax@snfax.com -t $4 -u "eFax message from $7 - $PAGES page(s), Caller-ID: $1" -a $5.pdf -o "message-file=$5.txt"
else
rm -f $5.txt
echo Dear $3, >>$5.txt
echo >>$5.txt
echo A call was recieved on your fax line, however no fax was recieved 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 " "$COUNT>>$5.txt
echo >>$5.txt
echo This notification is for your conveniance, if it is not required please notify your system administrator >>$5.txt
echo >>$5.txt
echo >>$5.txt
echo Thank you for using $6 >>$5.txt
echo sendEmail -f msalaque@vacl.us -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 -s d.com -xu d@d.com -xp d -f fax@snfax.com -t $4 -u "eFax error message: From Caller-ID: $1" -o "message-file=$5.txt"
exit
fi
====================================== END =========================================
Ok like always if you can't do that I could help. I will charge 200 US$ for this . I work as prepaid .
I always like to get involved new / challenging project. I got one . One of my client likes to have FAX to Email service at a very minimum cost.
Project: Install FAX to Email service using 100% freeware and open source Platform.
Same as before: I tried Google and found quit lot information. But none of them [I found] gave me total step by step solution.
I like to share my experience and solution with everyone.
Target :
FAX to Email service.
Software and Hardware I used:
OS: CentOS release 6.2 [64bit] .
Server: Dell R510.
Asterisk version: Asterisk 10.4.0
Some tools need to make tiff to pdf and send email using smtp :
*. yum install poppler-utils.x86_64
*. Download sendEmail-v1.56.tar.gz and setup . very easy just read the README .
Setup:
1. Install the Asterisk : you could do that or you don’t need to do FAXing.
2. Go to http://store.digium.com/products.php?category_id=94 buy [FREE or Paid. I use FREE] Fax for Asterisk License. After purchase they will email you the license key.
3. Go to http://downloads.digium.com/pub/register/ download the register file. I used x86-64.
4. Chmod +x register
5. ./ register and it will ask you for KEY. Follow the steps.
6. Go to http://www.digium.com/en/docs/FAX/faa-download.php. Download the files what matches your system .
I used 64bit and Flavor: Core 2 [http://downloads.digium.com/pub/telephony/fax/res_fax_digium/asterisk-10.1/x86-64/res_fax_digium-10.1_1.3.0-core2_64.tar.gz]
7. untar the file and copy res_fax_digium.so to /usr/lib/asterisk/modules/ and res_fax_digium.conf to /etc/asterisk
8. Reboot your system
Verify the setting: bellow is my running system log.
asterisk –r
did*CLI> fax show stats
FAX Statistics:
---------------
Current Sessions : 0
Reserved Sessions : 0
Transmit Attempts : 0
Receive Attempts : 9
Completed FAXes : 9
Failed FAXes : 2
Digium G.711
Licensed Channels : 1
Max Concurrent : 1
Success : 7
Switched to T.38 : 0
Canceled : 0
No FAX : 0
Partial : 1
Negotiation Failed : 0
Train Failure : 1
Protocol Error : 0
IO Partial : 0
IO Fail : 0
Digium T.38
Licensed Channels : 1
Max Concurrent : 0
Success : 0
Canceled : 0
No FAX : 0
Partial : 0
Negotiation Failed : 0
Train Failure : 0
Protocol Error : 0
IO Partial : 0
IO Fail : 0
did*CLI> fax show settings
FAX For Asterisk Settings:
ECM: Enabled
Status Events: On
Minimum Bit Rate: 2400
Maximum Bit Rate: 14400
Modem Modulations Allowed: V17,V27,V29
FAX Technology Modules:
DIGIUM (Digium FAX Driver) Settings:
Maximum T.38 Packet Delay: 800
T.38 Session Packet Capture: Off
G.711 Session Audio Capture: Off
did*CLI> fax show licenses
Fax Licensing Information
==============================
Free fax licenses: 1
Total licensed ports: 1
Licenses Found:
File: FFA-XXXXXXXXXXX.lic -- Key: FFA-XXXXXXXXXXXXX -- Product: XXXXXXXX -- Host-ID: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -- Ports: 1 (OK)
did*CLI> fax show version
FAX For Asterisk Components:
Applications: 10.4.0
Digium FAX Driver: 10.1_1.3.0 (optimized for core2_64)
did*CLI> fax show capabilities
Registered FAX Technology Modules:
Type : DIGIUM
Description : Digium FAX Driver
Capabilities : SEND RECEIVE T.38 G.711 MULTI-DOC
1 registered modules
Now: Extension and Context:
Sip.conf :
[general]
XXXXX
t38pt_udptl = yes
allow=all
allowguest=no
XXXXX
; provider
[My provider]
type=peer
insecure=port,invite
host=1.1.1.1
canreinvite=no
allow=all
qualify=no
nat=yes
dtmfmode=rfc2833
t38pt_udptl=no
exentsion.conf
[macro-startfax]
exten => s,1,Set(FAXOPT(ecm)=yes)
exten => s,n,Set(FAXOPT(maxrate)=14400)
exten => s,n,Set(FAXOPT(minrate)=2400)
exten => s,n,NoOp(FAXOPT(ecm) : ${FAXOPT(ecm)})
exten => s,n,Set(EXTEMAIL=a@s.com)
exten => s,n,Set(EXTNAME=VACL)
exten => s,n,Set(EXTCOMPANY=SNFax www.snfax.com)
exten => s,n,Set(FAXFILE=/var/spool/asterisk/fax/${CALLEDFAX}/${UNIQUEID})
exten => s,n,ReceiveFAX(${FAXFILE}.tif)
exten => s,n,Hangup
[fax]
exten => xxx,1,Macro(startfax)
exten =>xxx,n,Hangup
exten => h,1,System(/var/lib/asterisk/scripts/mailfax "${CALLERID(num)}" "${CALLEDFAX}" "${EXTNAME}" "${EXTEMAIL}" "${FAXFILE}" "${EXTCOMPANY}" "${CALLERID(name)}")
;Debuging log
exten => h,n,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(error) : ${FAXOPT(error)})
[default]
;FAX extension
exten => xxx,1,Wait(2)
exten => xxx,n,Ringing()
exten => xxx,n,Set(CALLEDFAX=${EXTEN})
exten => xx,n,Goto(fax,${EXTEN},1)
;End Fax setting
Script : I found it from google and did some modification :
echo Received paramters $1 $2 $3 $4 $5 $6 $7 >>/var/log/faxmail.log
DATETIME=`date +"%A %d %b %Y %H:%M"`
if [ -e $5.tif ]
then
/usr/bin/tiff2pdf -p A4 $5.tif -o $5.pdf
echo fax file $5.pdf found. Sending email to $4 .... >>/var/log/faxmail.log
PAGES=$(pdfinfo $5.pdf | grep "Pages")
DT=$(pdfinfo $5.pdf | grep "ModDate")
DTFAX=${DT#*:}
COUNT=${PAGES#*-}
rm -f $5.txt
echo Dear $3, >>$5.txt
echo >>$5.txt
echo You have just recieved a new fax document. Details as follow >>$5.txt
echo >>$5.txt
echo "From : "$1 >>$5.txt
echo "To : "$2 >>$5.txt
echo "Date Time : "$DATETIME " Eastern Daylight Time [EDT,New York]">>$5.txt
echo "Number of "$COUNT>>$5.txt
echo >>$5.txt
echo >>$5.txt
echo Thank you for using $6 >>$5.txt
echo sendEmail -f fax@vacl.us -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 -s d.com -xu d@d.com -xp aaa -f fax@snfax.com -t $4 -u "eFax message from $7 - $PAGES page(s), Caller-ID: $1" -a $5.pdf -o "message-file=$5.txt"
else
rm -f $5.txt
echo Dear $3, >>$5.txt
echo >>$5.txt
echo A call was recieved on your fax line, however no fax was recieved 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 " "$COUNT>>$5.txt
echo >>$5.txt
echo This notification is for your conveniance, if it is not required please notify your system administrator >>$5.txt
echo >>$5.txt
echo >>$5.txt
echo Thank you for using $6 >>$5.txt
echo sendEmail -f msalaque@vacl.us -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 -s d.com -xu d@d.com -xp d -f fax@snfax.com -t $4 -u "eFax error message: From Caller-ID: $1" -o "message-file=$5.txt"
exit
fi
====================================== END =========================================
Ok like always if you can't do that I could help. I will charge 200 US$ for this . I work as prepaid .
Comments
Post a Comment