Personal tools
You are here: Home / OSCAR EMR version 12.x / 4.0 Developers / 4.5 OSCAR Faxing / 4.5.3 Internet Faxing

4.5.3 Internet Faxing

Faxing to an internet email to fax gateway from Oscar is easy and convenient.

Preface

This is a basic installation of a mail to fax server for use with Oscar.  Security details are not covered

Document Version History

  • v1.0 – initial public release to oscarmanual.org – August 20, 2012
  • v1.1 – fixed argument order for mutt – Sept 9, 2012
  • v1.2 – clarified a few instructions and allowed for variations – May 27, 2013
  • v1.3 – added postfix notes and bellfax.ca to eFax providers
  • v1.4 – added SRfax provider – Jan 25, 2015
  • v1.5 – wrapped with a check for files – Jul 15, 2015
  • v1.6 – added content sensitive coded fax subject – Dec 2, 2015
 copyright ©2012-2015 by Peter Hutten-Czapski MD under the Creative Commons Attribution-Share Alike 3.0 Unported License

 

Contents

  1. Preface
  2. Document Version History
  3. Prerequisites
  4. Installing Server Packages

Prerequisites

It is assumed that

  1. You have installed a Debian based Linux (tested on Ubuntu 10.04+)
    We recommend Ubuntu 12.04 LTS with full disk encryption
  2. You have a basic level of Linux knowledge
  3. You can open a Linux terminal
  4. You can cut and paste EXACTLY the following instructions
NOTE: Firefox will copy with Control+C while a Linux terminal requires Shift+Control+V for paste

Installing Server Packages


Postfix is the default Mail Transfer Agent (MTA) for Ubuntu. It receives security updates but poor configuration of your firewall and the program itself can make it vulnerable.  Securing the installation is beyond the scope of these instructions.

Postfix can be used to send the email to your ISP's SMTP (outbound) server, who then forwards it to the eFax gateway for transmission. This can get very complicated, since each SMTP server can be setup differently. See Postfix SMTP Setup, below for notes. 

Mutt  is a small but very powerful text-based mail client (mail user agent MUA) for Unix operating systems that can MIME encode file attachments.

An Internet Fax Gateway is a commercial subscription service that allows for conversion of email to fax and vice versa, fax to email.  The main advantage of this service over the Hylafax method is that the phone line and the modem are provided.  The main costs are the need for internet connectivity and the gateway subscription cost.

Install Postfix and Mutt by typing or pasting the following into the command line.

sudo apt-get install postfix mutt

Simply accept the defaults or provide the obvious particulars when the installation process asks questions. For most people the defaults will be fine, and you can change them if you get them wrong with the following command.

sudo dpkg-reconfigure postfix

I  recommend that you use the default debian approach of specifying your mailname (the mailname part of user@mailname eg oscarhaileybury.org) as the first line in the file /etc/mailname and activate it by putting in the following line in /etc/postfix/mail.cf

myorigin = /etc/mailname

Of course you will likely have to ensure that your router has port 25 open to route the email to the internet and eventually your fax gateway (more below).

NOTE: For security (ANY production use) configure Postfix to do SMTP AUTH using SASL (saslauthd) with instructions from https://help.ubuntu.com/community/Postfix

 

Postfix SMTP Setup

You can use mutt to test postfix. Use 'sudo mutt -s "Test Email" <yourname>@gmail.com' to send a test email to your gmail account.

Mutt will display the To: and Subject:  (which you can edit). It will then open an editor window, where you can type the text of your email. When you close the editor, you will see the main mutt screen. Enter y to send the email.

You can view the mail log by using 'sudo tail /var/log/mail.log'. Note: It may take a few minutes to be processed.

Pay special attention to the from=<emailaddress> and any error messages. The from=<emailaddress> may be very important for your eFax gateway. SRFax and Bell Fax check for valid email addresses. The relay= shows the SMTP server and port being used. This must match the servername and port used by your ISP.

GoDaddy.com: SMTP: smtpout.secureserver.net  Port: 3535

edit /etc/postfix/sasl_passwd: and add smtpout.secureserver.net user@mydomain.com:MySecretPassword

 

Now a cron job

With the  deb installation Oscar drops faxes into /tmp/tomcat6-tmp as matching txt files with the fax number and pdf for the image to be faxed.  These files can be parsed by a script that runs regularly, and assembled into an email that is sent to the email to fax gateway provider.

We don't recommend any Internet Fax Service in particular, just be aware that American providers may not be able to give you a local outgoing number necessary to fax to "local" 1-800 numbers that are only valid in province.  Such providers are also subject to the Patriot Act which potentially contravenes Canadian privacy rules.  Consider SRfax, Prestofax, Bell and Telus for Canadian providers.

It depends on how the email  to fax gateway authenticates as to how you adjust the script to match.  Almost invariably the destination email address is in the form faxnumber@gateway.com and the fax image is handled as a MIME encoded attachment. 

For Prestofax, by example and shown below, the authentication is based on a number in the subject heading, replace <security code> with the actual number.  

In most cases you will need to set your fax gateway account to accept faxes sent with the from email which you set in postfix configuration above. To recap the from email is a combination of the user who runs the gateway.cron script (more precisely the user who is invoking Mutt), ie tomcat6 or root and the suffix that you set in /etc/mailname above and referenced in Postfix config as myorigin eg oscarhaileybury.org for a combined sending email as root@oscarhaileybury.org.

Save the following as gateway.cron. (note that you should check the path for the tmp file, it can be /tmp/tomcat6-tomcat6-tmp/)

#!/bin/bash
#
# Fax Gateway cron
# Picks up the files dropped by OSCAR for faxing
# For Prestofax you need to replace <security code> with the number associated with your account
# Make sure you adjust the paths and mutt switches appropriately
#
if test -n "$(find /tmp/tomcat6-tomcat6-tmp -maxdepth 1 -name '*.txt' -print -quit)"; then 
	for f in `ls /tmp/tomcat6-tmp/*.txt`; do 
	   t=`echo $f | sed -e s"/\/tmp\/tomcat6-tomcat6-tmp\///" -e s"/[-_][0-9]*.txt//" -e s"/prescription_/Rx-/"`
		mutt -s "Oscar Fax $t <security code>" `sed s"/ *//g" $f|tr -d "\n"`@prestofax.com -a `echo $f | sed s"/txt/pdf/"` < /dev/null
		rm $f; 
		rm `echo $f | sed s"/txt/pdf/"`; 
	done  
fi

For SRFax use something like the following for the line beginning with mutt above.

mutt -s "Oscar Fax" 1`sed s"/ *//g" $f|tr -d "\n"`@srfax.com -a `echo $f | sed s"/txt/pdf/"` < /dev/null

For Bell, the transmission must be from a known email address. (eg. fax@clinic_name.com). 

mutt -e "Oscar Fax" `sed s"/ *//g" $f|tr -d "\n"`@bellfax.ca -a `echo $f | sed s"/txt/pdf/"` < /dev/null

For Telus an optional password can be enabled that is in the body of the email.

Now make it executable

chmod 777 gateway.cron

And set it up as a cron job (you will need to run it as root or as tomcat6 user to open the files that are dropped by Oscar into the tmp directory.)  The following example has the root user sending the email to the fax gateway

sudo crontab -e
And add an entry like the following that executes every 3 minutes
*/3 * * * * /home/peter/gateway.cron

Document Actions