Skip to main content

This will setup the Raspberry Pi to act as a mail server that will take any emails sent to mail2fax@myfaxserver.example.com and will send out a fax from that received email. The PI  makes a great, low-power-draw server with a USB modem. A modem that works well is the U.S. Robotics USR5637 56K USB Controller Dial-Up External Fax Modem with Voice

Notes on setting it up for postfix and mail-to-fax capabilities

* Get and boot with Raspian

* Find out what com port is assigned to the modem

find /sys/bus/usb/devices/usb*/ -name dev | grep tty

You should get something like

/sys/bus/usb/devices/usb1/1-1/1-1.5/1-1.5:2.0/tty/ttyACM0/dev

Which means that it's assigned to ttyACM0

* Install the packages:

sudo apt-get install hylafax-server mailutils postfix cu html2ps t1-xfree86-nonfree fonts-freefont-ttf texlive-fonts-recommended 
sudo apt-get install ttf-mscorefonts-installer fonts-croscore fonts-freefont-otf t1-cyrillic texlive-fonts-extra
 

The mscorefonts might not be free for commercial usage,

* Run the hylafax add modem package

sudo faxaddmodem

* Edit the file /var/spool/hylafax/etc/config Should have that file with something like this

 

LogFacility:            daemon
CountryCode:            1
AreaCode:               608
LongDistancePrefix:     1
InternationalPrefix:    011
DialStringRules:        etc/dialrules
ServerTracing:          1

* Configure the USR USB modem

vi /var/spool/hylafax/config/usr-*

*  Remember above when you found out it was using ttyACM0? If that's what it is set on your Pi then edit this file /var/spool/hylafax/etc/config.ttyACM0 and change the ModemFlowControl to this:

ModemFlowControl:       rtscts          # Changed software flow control

* See if the modem is detected and running

sudo faxgetty /dev/ttyACM0

* The script mail2fax.sh will run the mail to fax feature . Edit the file /usr/local/bin/mail2fax.sh if you want  the outbound fax to only be identified as "faxserver" instead of MYNAME.EXAMPLE.COM or whatever the full tld name of the machine is. For example ...

#hide actual server name from outbound fax
sed -i 's/MYNAME.EXAMPLE.COM/faxserver/g' $RANDOMFAX/_message_
sed -i 's/MYNAME2.EXAMPLE.COM/faxserver/g' $RANDOMFAX/_message_

also Note that the default for mail2fax.sh is for Hylafax+ not Hylafax so comment out the cat command and replace it like so

#Change from Hylafax+ to Hylafax for formatting to mail.
#cat $RANDOMFAX/_message_ | faxmail -v -T $FROMPATH | sendfax -vv -n -D -f "$FROMPATH" -i "$JOBID" -d $TONUMBER
cat $RANDOMFAX/_message_ | faxmail -v -u pi -n "faxserver@$TONUMBER"

* So you'll send emails to mail2fax@your.machine.name. Setup the aliases to handle mail to  mail2fax@example.com. Edit /etc/aliases and add the following aliases

faxmaster:      your_email_here@example.com
mail2fax: |/usr/local/bin/mail2fax.sh

* Setup Postfix:  Add the following text to the end of /etc/postfix/main.cf

#Added for hylafax, acccept users matching the following
virtual_alias_maps = hash:/etc/postfix/valias


Create the file /etc/postfix/valias with the text (replacing full.machine.name with the machines full name)

@full.machine.name   mail2fax

Then run the following

cd /etc/postfix/
sudo postmap valias
sudo newaliases
sudo postfix reload