If everything has been set up properly, faxes will be received
automatically. Obviously, mgetty has to be listening to the proper modem
line. Then, if a fax arrives, mgetty will store it in the directory
FAX_SPOOL_IN
(or the directory configured in mgetty.config,
see runtime-mgetty) and send a mail to MAIL_TO
(defined
in policy.h).
The file name format is somewhat tricky (the reason behind it is that I
have to create something unique without using mktemp()
, because that
would make it impossible to find out which pages belong to which fax). It
is:
f<res><seq><line>[-<remote id>].<pagenr>
<res>
is n
or f
, depending on the resolution of the
fax. <seq>
is a sequence number, 7 digits wide, somewhat related to
the reception time. <line>
are the last two letters of the tty
device, e.g. S1. If the sending side specified a fax station id,
it comes next, after a leading dash (all blanks are replaced by dashes).
Finally, after a dot, you’ll see the page number.
If you want to process incoming faxes automatically, for example, print them, re-send them to another fax, send them by mail to you when you’re on vacation, you could use what I call “notify programs”:
If you define FAX_NOTIFY_PROGRAM
in policy.h, mgetty
will call this program (or shell script) when a fax has been completely
received. It will be called with the following command line arguments:
FAX_NOTIFY_PROGRAM <hangup code> '<sender id>' <nr of pages> \ <file name page 1> <file name page 2> …
<hangup code> is 0 if the receive was successful, non-zero otherwise. <sender id> is the fax identification string received from the other side. <file name page (i)> is the full path name for each received page.
A sample command line might look like this:
/usr/local/bin/new_fax 0 "+49 89 3243328" 1 /var/spool/fax/ff-01.a123
In addition, some environment variables are provided: CALLER_ID
,
CALLER_NAME
, CALLED_ID
(Caller ID and destination ISDN MSN,
if available and supported by your modem), CALL_DATE
, CALL_TIME
,
and DEVICE
(the full name of the tty device, if you want to process
faxes differently depending on the line they came in).
Such a “notify program” could print out the fax, convert it into a MIME metamail and send it away, display it in an X window (this a little bit tricky), or whatever. (A friend of mine uses it on his Linux box to call a program that will make the keyboard LEDs blink when a fax has arrived – as you can see, maximum flexibility is possible).
I provide a few examples (printing on HP laserjet, mailing as gzip’ed, uuencoded pbm file, …) in samples/new_fax.*
If you have the dialog
shell tool, you can use the faxv
program (“faxview”) that I provide in frontends/dialog/faxv to
browse through all faxes in the incoming spool directory, view them, print
them, rename and move them, …. faxv is really more a sample
program to show you how to do it, and you have to configure the X11 viewer
and the printing program in the source code, but I use it for my faxes, and
it works. Because of limitations on some operating systems, the list of
faxes displayed is limited to the last 50 faxes received.