There was a reason I moved all the fax emailing out of the dialplan.  When
I was first trying this out (over a year ago now I think) I found using the
System() call in the asterisk dialplan unreliable.  I could never pin down
exactly what was going on and things may have improved now.  Symptoms were
that it would appear that the linux system process would kick off and for
some reason never exit.  Using multiple System() calls back-to-back seemed
to make things worse.

David

On Tue, Feb 14, 2012 at 6:11 PM, Lonnie Abelbeck
<[email protected]>wrote:

> 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=
> [email protected]>
> > 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].
>
------------------------------------------------------------------------------
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].

Reply via email to