Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Server
User Name
Linux - Server This forum is for the discussion of Linux Software used in a server related context.


  Search this Thread
Old 02-15-2016, 08:36 AM   #1
Registered: Mar 2015
Distribution: debian 8 &9, ubuntu 16.04, centos 6&7
Posts: 56

Rep: Reputation: Disabled

hello everyone. i do have an installation of ubuntu 12.04 LTS server edition 32bit. In that server i do run my office PBX and by making use of iaxmodem and hylafax i can receive faxes directly to emails. if i want to sent faxes i have to use the CLI with the sendfax command.
i would like to automate the process by sending emails with an attachment and then the sendfax command will be issued to send the fax.
the following email addresses are fakes ones, just for the sake of the simplicity
i have created some email address

I would like to setup the email address to the server. when it receives an email with the format

It will receive only from the following email addresses,,
the user that sends the email need to get a report back with the success or failure of the fax.
i do need some help on how to set it up on the system please. i am lost.
Old 02-15-2016, 08:54 AM   #2
Senior Member
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
Lets say you have a working mail server. The mails come in and are stored in the users mail directory. Now you can either use procmail recipe to process the mail or use a cronjob that searches through some user mail directories. What you need as well is a script that gets the attachment and send it over the fax. As you say you use the cli and sendfax to do this. This part should be done quite fast. Create a bash script that takes two arguments. First the number to send to, second the file to send. Within you have the cli command and some initiale variable checks, path checks, binary checks. This script can be called from the procmail recipe.
Old 02-15-2016, 09:08 AM   #3
Registered: Jan 2012
Location: South Africa
Posts: 501

Rep: Reputation: 189Reputation: 189
Hi there,

Here are some pointers that might help.

As you mentioned in the subject, you can fetch the mail from gmail with fetchmail. You can send the mail to a local alias, which pipes the message to a script (/etc/aliases).

The script will need to extract the content you need.

It can then send the fax with the "faxmail" command - see

Here is a very crude example script I used years ago:


BASENAME=$(basename $0 .sh)

cat - > $INPUT
DEST=$(grep '^Subject:' $INPUT|cut -d: -f2)
FROM=$(grep '^From:' $INPUT|cut -d: -f2)
date >> $LOG
echo "Fax from '$FROM' to '$DEST'" >> $LOG
faxmail -d -n -s a4 $DEST < $INPUT
exit 0
The gets the destination from the subject line, logs the request to a logfile, and passes the message to faxmail for further processing & delivery.

This will work for plain text messages and some basic attachment types like PostScript & images, but not PDF as far as I recall. It does allow you to create your own "MIME converter", though. For PDF, you can convert it to PostScript with GhostScript (gs). There's an example for this at

I hope this helps.




Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Fetchmail to get Gmail Emails into ~/Mails/inbox? Xeratul Linux - Newbie 4 04-22-2013 03:08 AM
any one use fetchmail mutt postfix to access gmail? Richard.Yang Linux - Software 16 08-23-2011 09:23 AM
[SOLVED] fetchmail and gmail repo Linux - General 1 03-29-2011 09:04 AM
[SOLVED] Problem getting gmail (local issuer certificate) with fetchmail Tim Johnson Linux - Software 4 10-07-2010 11:00 AM
Fetchmail with Gmail RySk8er30 Linux - Software 1 04-16-2005 02:37 PM > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 09:53 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration