LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


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

Rep: Reputation: Disabled
fetchmail+gmail+fax


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
atuxA@gmail.com
atuxB@gmail.com
atuxC@gmail.com
atuxD@gmail.com

I would like to setup the email address atuxA@gmail.com to the server. when it receives an email with the format
to:atuxA@gmail.com
subject:the_fax_number
attachment:a_pdf_file.pdf

It will receive only from the following email addresses atuxB@gmail.com, atuxC@gmail.com, atuxD@gmail.com
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, 09:54 AM   #2
zhjim
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, 10:08 AM   #3
cliffordw
Member
 
Registered: Jan 2012
Location: South Africa
Posts: 500

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 http://www.hylafax.org/howto/clients...ndom-host.html

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

Code:
#!/bin/bash

BASENAME=$(basename $0 .sh)
TMP=/tmp/$BASENAME.$$
INPUT=$TMP.in
LOG=/tmp/$BASENAME.log

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
rm $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 http://hylafax.sourceforge.net/howto...converters.php.

I hope this helps.

Regards,

Clifford
 
  


Reply


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 04:08 AM
any one use fetchmail mutt postfix to access gmail? Richard.Yang Linux - Software 16 08-23-2011 10:23 AM
[SOLVED] fetchmail and gmail repo Linux - General 1 03-29-2011 10:04 AM
[SOLVED] Problem getting gmail (local issuer certificate) with fetchmail Tim Johnson Linux - Software 4 10-07-2010 12:00 PM
Fetchmail with Gmail RySk8er30 Linux - Software 1 04-16-2005 03:37 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 05:02 AM.

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