The Easy Fax Server!

ArticleCategory:

Applications

AuthorImage:

HackLinux

TranslationInfo:

Original in fr HackLinux

fr to en:John Perr

AboutTheAuthor:

It's been a long time since I used Windows and it feels good...

Abstract:

This article explains how to configure a Linux box as a fax server!

ArticleIllustration:[This is the title picture for your article]

www.hylafax.org

ArticleBody:

Introduction

Here is a configuration for a fax server using Hylafax 4.0pl2.rjc11 and a Mandrake 7.1 distribution

On the server side, Hylafax consists of 3 daemons :

On the client side, one finds the following programs (which can also run on the server) :

Relevant configuration files are found in the /var/spool/fax/etc/ folder

Installation

I strongly advise you to install the following packages (included with Mandrake 7.1) :

These resources are also available on the official site http://www.hylafax.org/links.html

If Hylafax is not installed by default, one simply has to add the needed RPM packages:

rpm -ivh hylafax-common-4.0pl2.rjc11-3mdk
rpm -ivh hylafax-client-4.0pl2.rjc11-3mdk
rpm -ivh hylafax-server-4.0pl2.rjc11-3mdk

Configuration of Hylafax

In order to configure the server, run the command:

faxsetup -server (as root)

The default settings are ok to use almost every question asked, except for:

Hylafax does not launch the daemon faxgetty by default. This has to be done by hand:

1 - Edit file /etc/inittab and insert the following line at the end of the file:

mo:2345:respawn:/usr/sbin/faxgetty -D ttyS0
the command kill -HUP 1 is necessary to restart faxgetty

Or

if you want to use the rc.local file:

2 - Add to /etc/rc.d/rc.local the following line:
/usr/sbin/faxgetty -D /dev/ttyS0

and launch the command:

faxgetty -D /dev/ttyS0

Note : The command faxaddmodem allows you to add one or more modems afterwards.

After these manipulations, the file /var/spool/fax/etc/config.ttyS0 (for com1) has been created for faxgetty.
It contains your modem configuration for /dev/ttyS0
The file /usr/share/fax/hfaxd.conf contains the hfaxd daemon configuration, I did not touch it!

If problems arise

To detect the modem, use the probemodem command. Moreover, there are typical configurations available in /var/spool/fax/config/

My modem is a 3Com US Robotics 56k, therefore I choose the file usr-2.0 which I copied into /var/spool/fax/etc/ while renaming it to config.ttyS0 and modifying it as follows:

# Configuration for using the Class 2.0 command interface
# with a USR v.34 Courier or Sporster modem.
#
# CONFIG: CLASS2.0: USRobotics*-*
#
CountryCode:         33
AreaCode:            1
#FAXNumber:          your number ex (for france): 0134123412
LongDistancePrefix:  0
InternationalPrefix: 00
DiadStringRules:     etc/dialrules.europe (Important .europe !)
ServerTracing:       1
SessionTracing:      11
RecvFileMode:        0600
LogFileMode:         0600
DeviceMode:          0600
RingsBeforeAnswer:   1
SpeakerVolume:       off
GettyArgs:           "-h %l dx_%s"
#LocalIdentifier:    "Your Company"   (uncomment if wanted on the fax)
#TagLineFont:        etc/lutRS18.pcf  (idem)
#TagLineFormat:      "De %%l|%c|Page %%p sur %%t" (idem)
#MaxRecvPages:       25
ModemType:           Class2.0    # use class 2.0 interface
ModemRate:           57600        # 38400 DCE-DTE communication rate
ModemFlowControl:    rtscts       # XON/XOFF flow control assumed
ModemDialCmd:     ATDT0%s # I added 0 because I go through a PABX !!
#ModemNoFlowCmd:     AT&H0&I0&R1  # setup modem for no flow control
ModemHardFlowCmd:    AT&H1&I0&R2  # setup modem for hardware flow control
#ModemSoftFlowCmd:   AT&H2&I2&R1  # setup modem for software flow control
#ModemSetupDTRCmd:   ATS13=1&D2   # setup so DTR drop resets modem
#ModemSetupDCDCmd:   AT&C1        # setup so DCD reflects carrier (or not)
ModemResultCodesCmd: ATQ0X4       # enable extended result codes
#ModemSetupAACmd:    AT+FAA=1
#ModemSetVolumeCmd:  "ATM0 ATM1 ATM1 ATM1 ATM1"
Class2BUGCmd:        AT+FBU=0
Class2CQQueryCmd:    !(0),(0)    # override modem response
Class2NRCmd:         AT+FNR=1,1,1,0


Next the following lines are added to /var/spool/fax/etc/host:

  localhost
  192.168.1

All machines from domain 192.168.1.0 are allowed to use the fax!

Starting Hylafax

In order to run Hylafax automatically at startup, use the command drakxservices (with Mandrake) or setup (with Red Hat),
next run manually the command:
/etc/rc.d/init.d/hylafax start 
If faxgetty does not exist in the process list (ps -e) try:
/usr/sbin/faxgetty -D /dev/ttyS0

Using Hylafax

To send a fax :
sendfax -n -d number file1 file2 ..
To check the result:
faxstat -s (shows fax in the queue waiting to be sent)
faxstat -d (shows faxes sent)
faxstat -r (shows faxes received)
 

To remove a fax from the queue:

faxrm number_of_job
To clean the spool :
faxqclean
To show statistics :
faxcron

Using Hylafax on a network

Configuration of the server

For network use, I chose the resources available from http://www.hylafax.org/links.html
Particularly Printfax and Repond, on site http://www.boerde.de/~horstf/:

Download these three files:

Copy script printfax.pl in /usr/bin/ and modify it such that it works with hylafax :

### Format of commandline
#    $cmdlinefmt='mgetty';
    $cmdlinefmt='hylafax';

### The faxspoolprogram
###   for mgetty+sendfax:
#    $faxspool = '/usr/bin/faxspool';
###   for hylafax:
    $faxspool = '/usr/bin/sendfax';

### Additional faxspool args (e.g. header, coverpage)
###   empty:
    @faxspool_args = qw(-n);
###   for mgetty+sendfax with a special header:
#   @faxspool_args = qw( -h /usr/local/etc/mgetty+sendfax/faxheader.smb);
###   for hylafax with send email when job is done or requeued and use
###   a4 sized paper:
#    @faxspool_args = qw(-D -R -s a4);


Note :Cross check your script version of printfax.pl, as modifications might have taken place!

Add module smb_conf.add in /etc/smb.conf using copy/paste:

  [Fax] comment = Fax Printer
  public = yes
  postscript = yes
  print command = ( /usr/bin/printfax.pl %I %s %U %m; rm %s ) &
  printable = yes
  writable = no
  path = /var/spool/samba

Check line print command especially with windows2000

Samba must now be restarted,

/etc/rc.d/init.d/smb restart

Configuration of a client

Here is a typical Client Configuration for WINDOWS 95,98,NT,2000... Install Respond.zip, which contains config.exe and respond.exe files :

Next a networked printer must be created:

This is the end of the road, open Wordpad, type any text and print it on the fax printer! The respond dialog box then appears (if you started respond.exe) asking you the fax number, just enter the number and Ok, your fax is going to be sent to the fax server hylafax

In order to check the correct behaviour, go to the server and type faxstat -s, your fax should be there.

Typical Client Configuration for Linux :

Use available utilities on the Hylafax site!

Mailing with Fax

Mailing with the fax is done locally on the server with StarOffice.

On the other hand, your database can be anywhere on the network and is accessed using StarOffice(ODBC,JDBC,...) Use the spadmin utility and configure the telefax output: faxspool (PHONE) (TMP)

Inside the document to fax put @@#num_tel_fax@@ transparently with a database field name instead of num_tel_fax

Read the StarOffice help, everything is explained!

The drawback of this method is that you have to install StarOffice on the fax server :-( Fax Mailing through the network using respond is not straightforward with StarOffice because a fax number must be entered manually for every recipient!
I am investigating at the moment an alternative solution.

Resources

http://www-phase.c-strasbourg.fr/inform/faxdoc/expose_fax/fonctionnement.html
http://www.hylafax.org

Notes from the author

If you find this document incomplete or filled with faults, please wrtite to [email protected] And if you have some spare time, think about signing the no patents request!