Howto?: Receive fax via Asterisk, convert to PDF or TIFF

I’ve looked over this forum and the wiki, and all Asterisk documentation I have, and haven’t found the answer yet.

I need to simply receive faxes via Asterisk, using a POTS phone line connected to a Digium TDM400 FXO port, and convert them to TIFF or (preferably) PDF, store them on the server, and preferably email them to a recipient (the “recipient” doesn’t have to be selectable by the fax sender).

Most of what I’ve seen here and on the wiki seems to deal with sending faxes out via Asterisk, or sending and receiving faxes via IP (SIP or IAX). I don’t need to be able to do that, at least not any time soon.

I can handle the “email faxes to a recipient” another way, if it’s not part of the Asterisk solution.

I think there are some solutions involving chaining to Hylafax or something like that. I have used Hylafax in the past and an learning a lot about Asterisk now, but have no idea how to chain Asterisk output to Hylafax.

Any pointers to online documentation showing how to do this?


i would also be very interested in learning more about this, as our company makes extensive use of this type of functionality…

Here’s how I did it. You can send it straight tto a printer or off in an email.

Three packages are required and must be built together (from the same release):

A DSP library, builds in /usr/local/lib - add the ld path to /etc/
Download from:
the latest end-user release version, then from an asterisk subdirectory there, get:

app_rxfax app_txfax:
Asterisk modules for fax send and receive
These go in the asterisk-1.2.x/apps directory, along with apps_Makefile.patch - which should be applied to the Makefile in the asterisk-1.2.x/apps subdirectory

app_nv_backgrounddetect or app_nv_faxdetect or both:
These are required where a shared line (voice/fax) is used. When fax-tones are detected, the call is sent to exten => fax … ct/(latest
fix include for stdio, for the first include:
#include <stdio.h>
find the line with (what happened??) and remove one ?
…(what happened?)\n):

add to the apps/Makefile:
I used backgrounddetect to play a recorded message on answer while listening for FAX tones:
exten => s,2,NVBackgroundDetect(welcome)
Alernatively, faxdetect with a five second wait with ring indicator can be used:
exten => s,4,NVFaxDetect(4|dt)
If dedicated fax DID is used, these detection routines aren’t required, just send it straight to a fax context.
See the wiki for details and bug-fixes: … VFaxDetect

A perl script mime-construct is required for emailing:

Other perl modules may be required (mime) you can pull from CPAN:
perl -MCPAN -e ‘shell’

A script for delivering incoming fax to email:


FAXFILE=$1 RECIPIENT=$2 FAXSENDER=$3 FAXID=/bin/date +%j%H%M%S.pdf

/usr/bin/tiff2pdf -p letter $FAXFILE | /usr/local/bin/mime-construct --to $RECIPIENT --subject “Fax from $FAXSENDER” --attachment $FAXID --type application/pdf --file -

I also just use straight to a properly configured postscript printer rather than invoking a script at all:
; Receive Fax on exten 2777
exten => 2777,1,Macro(faxreceive)
; on hangup ship the fax out
exten => h,1,system(/usr/bin/tiff2pdf -p letter -f ${FAXFILE} |/usr/bin/lpr -T"FAX from ${CALLERIDNUM} ${CALLERIDNAME}" -Plaser)



exten => s,2,NVBackgroundDetect(welcome) ; listen for fax tones

; Receive Fax on exten 2115
exten => 2115,1,Macro(faxreceive)
; on hangup ship the fax out
exten => h,1,system(/usr/local/sbin/mailfax ${FAXFILE} ${EMAILADDR} “${CALLERIDNUM} ${CALLERIDNAME}”)

exten => s,1,Set(FAXFILE=/var/spool/asterisk/fax/incoming/${UNIQUEID}.tif)
exten => s,2,Set(
exten => s,3,rxfax(${FAXFILE})

include => parkedcalls

; If fax is detected
exten => fax,1,Goto,fax|2115|1
exten => 2115,1,Goto,fax|2115|1

This is on RHEL4 and friends with tiff2pdf installed, ignore my extensions, etc., these are from working examples.

Good luck, all of the above is my very short digest (cheat sheet) of pretty much readily available information. As always, your mileage may vary…


I use iaxmodem and hylafax and it works fine.