[asterisk-users] FAX Installation in Asterisk

Ruben Rögels ruben.roegels at jumping-frog.org
Thu Jan 12 06:45:20 CST 2012


Am 12.01.2012 12:44, schrieb mahesh katta:
> Hi,
> 
> Any one give me about FAX in Asterisk.
> 
> PSTN====>FXO GATEWAY====>ASTERISK-1.4.27(OR)ASTERISK-1.8.X.X
> 
> whenever some one is Fax to PSTN its convert into pdf format....
> 
> Help me any links or pdf .. for setup this. ?
>  
> 
> Best Regards,
> 
> Mahesh Katta
> **

Hi Mahesh,

this is my macro in asterisk to handle fax:

[macro-faxin]
; Faxe
; ARG1 = eMail-Adresse
exten => s,1,Verbose(${BOUNDARY} Eingehender Ruf von ${CALLERID(num)})
exten => s,n,Verbose(${BOUNDARY} BCHANNELINFO ${BCHANNELINFO})
; nur verarbeiten, wenn B-Kanal frei ist
exten => s,n,GotoIf($[${BCHANNELINFO} = 2]?hangup:free)
exten => s,n(free),NoOp()
exten => s,n,Set(TO=${ARG1})
exten => s,n,Set(EXT=${MACRO_EXTEN})
exten => s,n,Verbose(1,${BOUNDARY} Eingehendes Fax ${CDR(uniqueid)})
exten => s,n,Set(FAXFILE=/tmp/fax-${TO}-${CDR(uniqueid)}.tif)
exten => s,n,Set(LOCALSTATIONID=jumping frog)
exten => s,n,Answer()
exten => s,n,Wait(3)
exten => s,n,ReceiveFAX(${FAXFILE},d)


This is an ugly work-around to handle fax properly becaus I can't catch
the hang-up event by the macro itself:


;fax oder kein fax, das ist hier die Frage...
exten => h,1,Verbose(${BOUNDARY} ${EXT})
exten => h,n,System(/usr/local/bin/fax2mail.sh ${FAXFILE} ${TO})

And this is the bash script to convert tif to pdf and send it via email
to my users:

#!/bin/bash

FAXFILE=$1
RECIPIENT=$2
SUBJECT="[Fax] Sie haben ein Fax erhalten"
BODYSUCCESS=/usr/local/bin/bodysuccess.txt
BODYFAILED=/usr/local/bin/bodyfailed.txt

PDF=/tmp/fax-`date +"%s"`.pdf



tiff2pdf $FAXFILE > $PDF

# Konvertierung okay?
if [ $? == 0 ]; then

        mutt -s "$SUBJECT" -a $PDF -- $RECIPIENT < $BODYSUCCESS

        # Hats geklappt?
        if [ $? == 0 ]; then

                exit 0

        else

                exit 1

        fi



else


        mutt -s $RECIPIENT < $BODYFAILED

        exit 1
fi


I hope this helps!

best regards,
Ruben





More information about the asterisk-users mailing list