Fax to Email to folder in Linux

Needed to move away from the single fax machine and find a better solution for receiving and processing faxes. Decided to move over to fax to email service and automating the extraction of fax images from the emails.
Tested on Centos, but should work on any Linux distro with a little tweaking.
You must have fetchmail and uudeview installed. use yum to install these.
*Recent updates of Centos warn you not to run fetchmail as root. You could either ignore this or run fetchmail as a non root user.

1. Signup for a faxtoemail service i.e www.efax.com and set the faxes to be forwarded to an email address eg fax@pratheesh.com as tif attachment.
Create a local user on Centos to retrieve the emails. lets suppose the user created is ‘fax’
Configure fetchmail to retrieve emails for this user
create file /root/.fetchmailrc with the following content
poll pratheesh.com protocol POP3 user fax password yourpassword is fax

Change permission for the created file
chmod 0710 /root/.fetchmailrc
create a script to fetch the emails and extract the attachment. create file /home/fax/retrievefax.sh with following content

#pop the mails from faxuser account frm mailserver
/usr/bin/fetchmail -a -v >> /var/log/fetchmail 2>&1
#run uudeview to strip attachment

/usr/bin/uudeview -i +a +o -q -p $TOSPLITFOLDER   $FAXUSERFILE
#clear the mailfile
cp /dev/null $FAXUSERFILE

Save the file and make it executable
chmod ugo+x /home/fax/retrievefax.sh
try sending a fax to your efax number and then run the script after a few minutes
sh /home/fax/retrievefax.sh

you can automate the execution by adding it as a cron job.

explanation of commands
in uudeview
-i suppresses interactivity
+a makes it append _1 instead of overwriting already existing file
+o stops overwriting
-q suppresses output messages ( so that cron does not send u mails)
-p to specify path where the decoded attachments should be sent

Tags: , , ,

One Response to “Fax to Email to folder in Linux”

  1. fax to email says:


    Being a ESL student, I think its great for me to know these news…. Thanks buddy


Leave a Reply