Creating a FAX Server
with HylaFAX
11/12/2007 On a stock SuSE installation, install HylaFAX (current version was 4.3.0 at the time of this writing). I decided to use an external modem to make the job easy (actually, I spent two days trying to get a WinModem to work in Linux.. good luck with that!). I plugged it into COM1, which meant that it was accessible via /dev/ttyS0 . Next, I ran faxsetup and used all of the default options (aside from area code and max pages). It automatically detected my USR Sportster and added all the correct options. In order to allow access to users on our subnet without having to supply a usename/password, I edited /var/spool/fax/etc/hosts.hfaxd and added the following line:
In order for hylafax to be able to communicate with your modem, you
must run faxgetty for each configured modem. Otherwise,
when you send a fax to the server, hylafax will just sit there with
the job doing nothing until the kill time expires. Faxgetty can be started
by simply typing /usr/lib/fax/faxgetty -D ttyS0 if you
want to start it manually; an easier way, at least in SuSE, would be
to add the following line to /etc/inittab:
This line was actually in the inittab file by default, it just had to be uncommented. In Fedora, I would probably run faxgetty from rc.local. HylaFax sends out reports when your job succeeds or fails, etc. To
change the email address that this is sent from, edit /etc/aliases
and change the following line:
To change modem settings, such as the number of rings to wait before answering look for a config.tty# file. For me, this file is /var/spool/fax/etc/config.ttyS0 (this file lets you set certain other key things as well, such as LocalIdentifier, which is usually the fax's phone number displayed at the top of each page). Things to look at:
I followed this suggestion to avoid problems with our USR Sportster:
Adding a second modem to an existing HylaFAX installation.. This proved to be stupid easy. The second modem that I was installing was the same model as the first modem, so I simply copied the old configuration. I did this manually by coping /var/spool/fax/etc/config.ttyS0 to /var/spool/fax/etc/config.ttyS1. (make sure to preserve the permissions! The config file should have permissions 644 with ownder fax:uucp). Next, I had to run faxgetty in order for HylaFAX to be able to communicate with the modem. The command I ran was /usr/lib/fax/faxgetty -D ttyS1. In addition, I added the following line to /etc/inittab so that it would run at startup and be respawned:
Once a second modem is configured, it can be dynamically added to Hylafax to send jobs with the faxmodem command. I did this by typing faxmodem ttyS1. I did not actually have to run this; as soon as I ran the faxgetty command, HylaFAX started using the modem immediately. Now, if I wanted to make the modem send-only, I could do it
one of two ways. The more complicated way would be to add a separate
modem class, set to send-only, and add the modem(s) to that class. The
easier, and recommended way as
described here, is to change the number of rings to 0 in the
config.ttySX file:
To make a modem receive-only, change the following setting in
the config.ttySX file:
Other programs to look at:
Some other solutions for interfacing with the FAX server: Frog FaxMail - I tried Frogfax 1.8.10.3 (without language pack) - Unfortunately, it froze every time I tried to fax. In Windows, the best way to fax is by using the whfc client:
To perform a Fax Merge from Microsoft Word, some
Word macros are made available at the WHFC site. I prefer the MergeFax
macro by Michael DeWitt.
Now, to perform a merge, you do it much like a Mail Merge:
Receiving Faxes At one point we decided we'd like to receive faxes with this fax server rather than just send. There are several ways to accomplish this; the two most typical ways are as follows:
We decided that the second way would be best. In addition, we wanted them in PDF format rather than the default of TIFF. To do this, I simply modified the /var/spool/fax/bin/faxrcvd script with the following changes (please not that it appears that faxrcvd is overwritten on HylaFax upgrades, but FaxDispatch is not; therefore customizations should be done the FaxDispatch file if possible):
The TOADDR email address would only receive notifications of any errors during reception of a FAX (although it could also be set to receive a notification of everything received). The SENDTO email address, on the other hand, would receive the PDF version of the FAX as an attachment (as well as some useful information in the email, including the number of pages, number received from, etc.) Note that this will NOT delete the original .TIF file! To do so, and delete the individual log at the same time, add the following lines to the end of the faxrcvd script:
Or, even better, add these lines to keep the files around for a few days just in case (ie. delete files older than 2 days):
Or, even better than that, use the utilities that come with HylaFax (faxcron and faxqclean) to clean everything! Run these via a cron job:
Notice that I have the faxcron program directing its output to the mail program so that a daily report is emailed to me. Also, an observation I made-- faxcron seems to do its math wrong. If you tell it to purge things older than two days, it actually only purges things older than three days. So, I actually changed all those 2's on the command line to 1's to account for this.
I also noticed that Outlook Web Access (OWA) does not interpret the Content-Type email header correctly and therefore neither names the attached file correctly nor realizes that it is a PDF. Instead, it merely looks at the file extension of the Content-Description header (which, of course, is completely incorrect behavior). To account for this, I changed the following lines in the faxrcvd script:
To change the email's From: address from the default of "The HylaFAX receive Agent," edit the /var/spool/fax/bin/dictionary file and set the DICTRECEIVEAGENT= line.
To send a fax from the command line on Linux, you should have the hylafax-client package installed and use the sendfax program (which is different than the sendfax program included in the sendfax package). Use a command similar to the following:
The -vv option will actually show you the FTP session. If it times
out with the following error...
...it is because sendfax will only use an ACTIVE FTP session. I cannot find any easy way to change this. Therefore, you must let the HylaFax server connect back to your machine from a random source port (it's usually tcp port 4558, but you never know). Add an iptables rule to allow that entire IP address to connect back, and voila!
When we started really using the fax server heavily in production to send out mass faxes, it became obvious very quickly that the default "killtime" of three hours (the time after which a fax in the queue is deleted, no matter if a send has even been attempted yet) was waaaay too short. It easily takes two minutes to send a four-page fax, and when you're sending a few hundred, the time adds up quickly. I upped the KillTime by adding the following line to /usr/lib/fax/sendfax.conf:
In fact, this does NOT work. I'm guessing that it will only work if you originally submit the fax through the sendfax command line utility from the same machine that contains that modified sendfax.conf. This did not actually work, at least not if the job was sent via WHFC. WHFC also does not let you change the value in the settings (it shows it to you, but does not let you alter it). Apparently though, you can change the following registry key (set this to the number of hours):
Hhhmmmm.. that did not work either. (to be continued...) Also, the maximum number of tries proved to be way too high. This is because busy signalswere automatically bumbed back up to the top of the queue. In other words, everything else in the queue had to wait until one number with a busy signal was tried twelve full times. I simply added the line Max Tries: 3 to /usr/lib/fax/sendfax.conf. Even better, check out this link for some finer tune settings regarding
things like busy signals:
To restrict what time outbound faxes are sent:
If you want to get any fancier, see here.
Logging outgoing faxes when done (completed or failed): http://hylafax.sourceforge.net/man/notify.php to customize: Because I wanted a log of ALL completed/killed outgoing faxes, but
I did not wish to have an email notification for successfully sent jobs,
I modified the bin/notify script so that it would NOT execute the main
section if the job's specified notification email was set to "none"
by adding the following lines to the MAIN section:
So, when submitting the job, I set the "notifyaddr" parameter to none and the notify parameter to done. This ensured that the notify script would be called (it will not be called unless both of these parameters are set to something) every time a job was done, for whatever reason.
OCR'ing incoming FAXes
PPS description here.
port 4559 tcp hylafax and hylafax-client rpm's installed. /var/spool/fax directory To customize the notification email(s):
Some important files: More documentation: |
|||||||||||||||||||||||