Switchvox - How do you send a fax through an h extension?
If you want to implement fax storing and forwarding methods, you may encounter the issue where Asterisk is unable to generate a new calls from the h extensions. Since the h extension is executed just before the channel destruction, it prevents any new calls from being placed.
In order to workaround this issue, you can call a script from theSystemapplication to generate a call file. When Asterisk reads this call file, a new call will be placed.
The script
#!/bin/bash
# $1 CALL ID: Used to name the filename
# $2 PEER: Used to set the PEER in which the call will be placed
# $3 DID : Number dialed on the peer
# $4 FAX IMAGE: Tiff image of the fax
# $5 ECM: Set if ECM is going to be enabled or disabled
# $6 MIN RATE : Sets Fax min speed
# $7 MAX RATE Sets Fax max speed
if [ "$#" -ne "7" ]; then exit 1; fi
echo "channel: $2/$3" > /tmp/$1.call
echo "application: SendFax" >> /tmp/$1.call
echo "data: $4" >> /tmp/$1.call
echo "setVar=FAXID=$1" >> /tmp/$1.call
echo "setVar=FAXOPT(ecm)=$5" >> /tmp/$1.call
echo "setVar=FAXOPT(minrate)=$6" >> /tmp/$1.call
echo "setvar=FAXOPT(maxrate)=$7" >> /tmp/$1.call
chmod 777 /tmp/$1.call
mv /tmp/$1.call /var/spool/asterisk/outgoing/
exit 0
Examples
Within extensions.conf, here's an example of how you would tell Asterisk to run this script:
exten => h,1,System (/path/to/file/fax.sh ${EPOCH} SIP/PROVIDER ${varDID} ${varNumber} ${varFILE} yes 2400 14400)
From the terminal, you would like to run the following command for testing purposes:
./fax.sh $(date +%s) SIP/PROVIDER 1234567890 fax.tiff yes 2400 14400