[Asterisk-Users] Re: Fax questions

Jesse Guardiani jesse at wingnet.net
Fri Apr 15 09:32:18 MST 2005


On Fri, 15 Apr 2005 07:14:03 +0800, Ronald Wiplinger wrote:

> There are so many fax information available, so that I am getting confused.
> 
> What I hope I can get to work:
> 
> Any extension should be able to receive fax, whereby via faxdetect the 
> fax should be sent to the email address as mentioned in voicemail.conf
> 
> Which packages should I install?
> How would be the dialplan for this? (as mentione above)
> I am using SuSE 9.2 Professional

I use Gentoo, so you'll have to figure out what to install from SuSe
yourself, but I installed the spandsp software, which gives you a nice
software fax modem, then I used this in extensions.conf to switch to
spandsp when a fax tone is detected and email it to my email address:

[macro-faxreceive]
exten => s,1,SetVar(FAXFILE=/var/spool/asterisk/fax/${UNIQUEID}.tif)
exten => s,2,DBGet(EMAILADDR=extensionemail/${MACRO_EXTEN})
exten => s,3,rxfax(${FAXFILE})
exten => s,103,SetVar(EMAILADDR=jesse at wingnet.net)
exten => s,104,Goto(3)

[fax]
exten => 2201,1,Macro(faxreceive)
exten => 2202,1,Macro(faxreceive)
exten => 2203,1,Macro(faxreceive)

exten => h,1,system(/usr/local/sbin/mailfax ${FAXFILE} ${EMAILADDR} "${CALLERIDNUM} ${CALLERIDNAME}")


NOTE: asterisk automatically jumps to the [fax] context if you are using
faxdetect in your zapata.conf

NOTE2: mailfax is a custom script I wrote. This is what it looks like:

---------------------- START mailfax script ------------------------------
#!/bin/sh

FAXFILE=$1
RECIPIENT=$2
FAXSENDER=$3
FAXID=`date +%j%H%M%S`
tempfoo="fax"
TMPFILE=`mktemp /tmp/${tempfoo}XXXXXX`
TMPFILE_A=`mktemp /tmp/${tempfoo}XXXXXX`.pdf


/usr/bin/tiff2pdf -p letter "${FAXFILE}" > "${TMPFILE_A}"
metasend -b -t "$RECIPIENT" -s "Fax from $FAXSENDER" \
  -f "${TMPFILE}" -m 'text/plain' -n \
  -m 'application/pdf;name="fax'${FAXID}'.pdf"' -f "${TMPFILE_A}" \
  -D 'PDF Fax Document'

rm "${TMPFILE}"
rm "${TMPFILE_A}"
---------------------- END mailfax script ------------------------------

I based this config on the excellent information found at the following
website:
    http://scottstuff.net/scott/archives/000152.html

But note that I heavily modified the mailfax script from the original
version. Why?
    1.) The original used the Perl mime-construct script, which has a lot
        of annoying Perl dependencies.
    2.) The original didn't send usable MIME attachments to me. Neither
        KMail or Evolution could successfully decode the attachment
        because the email contained no text/plain part.
My script uses metasend from the metamail package, instead of
mime-construct, and it adds an empty text/plain section at the beginning
of the email so that KMail and Evolution and probably other mail clients
can decode the attachment properly. The trade off is that it has to use
temporary files. Uck. :)

Anyway, the above does everything you need, except the ability to email
the fax to an email specified in voicemail.conf. You'll have to figure
that part out yourself. The above simply emails the message to a static
address. No DIDs or anything.

Also, you'll probably have to change some of the paths for things like
tiff2pdf and metasend.

HTH!

-- 
Jesse Guardiani, Systems Administrator
WingNET Internet Services,
P.O. Box 2605 // Cleveland, TN 37320-2605
423-559-LINK (v)  423-559-5145 (f)
http://www.wingnet.net






More information about the asterisk-users mailing list