HylaFAX The world's most advanced open source fax server

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [hylafax-users] faxmail prologue / created ps contains leading blank page



Tony Delov wrote:

Lee Howard wrote:

What you probably really want is to just write some very simple shell code taking the mail from your MDA, decoding the attachment, and then faxing the attachment with sendfax.

This is something I could do with as well.
I would love to hear of anyone that uses any such scripts and how they might have it set up.


Your MTA/MDA will pass e-mail on standard input to other programs... so in an easy example, you would use a .forward file or a pipe in your aliases file to pass the e-mail to an executable shell script like this:

#!/bin/sh
cat > file.mail

This effectively sends the mail that was passed to the script on standard input into the file.mail file. From here you can parse the e-mail headers or body for information by which to determine fax destination and other parameters... and you can decode any base64 MIME attachments or uuencoded attachments and attach those decoded files to your sendfax command. So as a very, very simplistic example:

#!/bin/sh
cat > file.mail
SUBJECT=`grep -e "^subject:" -i file.mail | sed q | sed -e 's/^[Ss]ubject:[ ]*//g'`
export METAMAIL_TMPDIR=/my/tmp/dir
metamail -w -x file.mail > /dev/null 2>&1
sendfax -d $SUBJECT /my/tmp/dir/*
exit $?


This will mail any attachments to the fax number in the subject line of the e-mail. Now that isn't a bullet-proof product - maybe it won't even run, but it should demonstrate how simple this really is. Most peoples' FaxDispatch files are going to be more complicated than this. And this will probably be just as customized as a FaxDispatch file, and thus there's not much of a point to creating a default "mail-to-fax" script for the HylaFAX distributions... it's just too simple to do and too often going to need more customizations than actual code.

Most of the work, I suspect, will be involved in learning your your MTA/MDA work and getting them to push the mail through to this... but if you have faxmail functional already, then just use this as a drop-in replacement, if you like. Command-line parameters get passed along as $1, $2, $3, etc. This should be a walk in the park.

Lee.


____________________ HylaFAX(tm) Users Mailing List _______________________ To subscribe/unsubscribe, click http://lists.hylafax.org/cgi-bin/lsg2.cgi On UNIX: mail -s unsubscribe hylafax-users-request@xxxxxxxxxxx < /dev/null *To learn about commercial HylaFAX(tm) support, mail sales@xxxxxxxxx*




Project hosted by iFAX Solutions