Hi Shamus,
Great to hear you got it working.
As an optimization you might try also using tiff2pdf as David did before
mailing, it should reduce the file size somewhat.
I haven't tried it, but the "tiff2pdf -j ..." option will definitely reduce the
file size. Play with some samples manually before changing your dialplan.
$ tiff2pdf -j -o file_name.pdf file_name.tiff
Lonnie
On Feb 14, 2012, at 1:26 PM, Shamus Rask wrote:
> David,
>
> Many thanks... I wanted to keep everything "in Asterisk" for ease of
> portability. I appropriated some of your code and am now using the following
> successfully:
>
> 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,System(echo -e "To: [email protected]\nSubject: FAX from
> ${CALLERID(all)}" | mime-pack "new fax" "${FAXDEST}/${tempfax}.tif"
> "application/tif" | sendmail -t)
> same => n,system(rm ${FAXDEST}/${tempfax}.tif)
> same => n,Hangup
>
> Many thanks for your suggestion!
> Shamus
>
> ------------------------------
>
> Message: 4
> Date: Sun, 12 Feb 2012 14:47:07 -0500
> From: David Kerr <[email protected]>
> Subject: Re: [Astlinux-users] fax - command to e-mail attachment
> To: AstLinux Users Mailing List <[email protected]>
> Message-ID:
> <CAJJxGdGcuKJjD0om3ADsv_74=dnoe9gzkuz_yxnr+g5mz5r...@mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> 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.
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
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].