I have moved the task of emailing received faxes outside of the asterisk
dialplan. Here is how I do it...
In the dialplan...
[DID_trunk]
;place following somewhere in your DID dialplan...
exten = fax,1,Gosub(fax-rx,s,1)
exten = fax,n,Hangup()
[fax-rx]
exten = s,1,NoOp(Receive FAX)
exten =
s,n,Set(emailaddr=${IF(${DB_EXISTS(actionlist/fax${CALLERID(dnid)})}?${DB_RESULT}:${DB(actionlist/fax)})})
exten =
s,n,Set(FAXFILE=/tmp/fax~${CALLERID(NUM)}~${emailaddr}~${FILTER(0123456789,${UNIQUEID})})
exten = s,n,Set(LOCALHEADERINFO=My Name)
exten = s,n,Set(LOCALSTATIONID=My Name)
exten = s,n,ReceiveFAX(${FAXFILE}.tiff) ;Asterisk 1.8
;exten = s,n,RxFAX(${FAXFILE}.tiff) ;Asterisk 1.4
exten = s,n,Log(NOTICE,New FAX: ${FAXPAGES} page(s) from ${CALLERID(NUM)}
(${REMOTESTATIONID}) to ${CALLERID(dnid)})
exten = s,n,Hangup()
exten = s,n,Return()
Notice how the destination email address is pulled from the astdb
actionlist, and that you can have different email destinations based on the
destination in callerid. This email address is then saved as part of the
.tiff filename created in /tmp, along with the CallerID number and a unique
identifier.
Then I have a task running in the background on my astlinux box. I call it
check_fax...
#!/bin/bash
#
background () {
while true;
do
for f in /tmp/*.tiff
do
if [ -f $f ]
then
fuser -s $f
if [ $? -ne 0 ]
then
tiff2pdf -o "${f%\.*}".pdf "$f"
mv -f "$f" /mnt/kd/fax
fi
fi
done
for f in /tmp/*.pdf
do
if [ -f $f ]
then
cidemail="${f%~*}"
cidemail="${cidemail#*~}"
email="${cidemail#*~}"
cid="${cidemail%~*}"
shortf="${f##*~}"
mv -f "$f" "/tmp/fax-$shortf"
echo "Subject: New FAX from $cid
From: AsteriskPBX
To: $email" | \
mime-pack "New FAX received from $cid" "/tmp/fax-$shortf" "application/pdf"
| \
sendmail -t
rm -f "/tmp/fax-$shortf"
fi
done
sleep 30
done
}
background&
echo $! > /tmp/check_fax.pid
This script is fired of every time astlinux boots by placing it in
rc.local...
#!/bin/bash
#
# /etc/rc.local - run once at boot time
# Put any local setup commands in here:
# inadyn --input_file /etc/inadyn2.conf
# mkdir /root/usb
/mnt/kd/bin/check_fax
Looking at the check_fax script... it looks for new faxes (.tiff files) in
/tmp. It converts all .tiff's into .pdf's (and moves the .tiff into
/mnt/kd/fax for backup/archive... you should erase those from time-to-time.
Then for all .pdf's created it emails them to the email address embedded
into the filename. Then erases the .pdf. Then it sleeps for 30 seconds
before checking again for more faxes.
David.
On Sun, Feb 12, 2012 at 1:28 PM, Shamus Rask <[email protected]> wrote:
> I'm running the latest version of AstLinux with Asterisk 1.8.x. Digging
> through the files, it looks as though AstLinux uses msmtp for e-mail
> notifications (voicemail, safeasterisk, SIP trunk status...).
>
> I was hoping to use it to send received faxes (*.tif files) to email
> recipients. The following snippet from my extensions.conf was lifted
> directly from O'Reilly's latest book on Asterisk:
>
> exten => fax,1,Verbose(3,Incoming fax)
> same => n,Set(FAXDEST=/tmp)
> same => n,Set(tempfax=${STRFTIME(,,%C%y%m%d%H%M)})
> same => n,ReceiveFax(${FAXDEST}/${tempfax}.tif)
> same => n,Verbose(3,- Fax receipt completed with status: ${FAXSTATUS})
> same => n,Hangup
>
>
> I've confirmed that a fax is detected and written to the /tmp directory
> through the Asterisk CLI. How do I take the received file and e-mail it
> out to recipients? Following successful e-mailing, is there a simple way to
> delete the file so as not to clog /tmp?
>
> cheers,
> Shamus
>
>
> ------------------------------------------------------------------------------
> Virtualization & Cloud Management Using Capacity Planning
> Cloud computing makes use of virtualization - but cloud computing
> also focuses on allowing computing to be delivered as a service.
> http://www.accelacomm.com/jaw/sfnl/114/51521223/
> _______________________________________________
> Astlinux-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/astlinux-users
>
> Donations to support AstLinux are graciously accepted via PayPal to
> [email protected].
>
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Astlinux-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/astlinux-users
Donations to support AstLinux are graciously accepted via PayPal to
[email protected].