Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[hylafax-users] Email to Fax script issue

536 views
Skip to first unread message

Scott Rich

unread,
Mar 1, 2011, 1:55:54 PM3/1/11
to hylafa...@hylafax.org
I am using the attached script for email to fax processing. However, when an email is sent to the server, I end up with 2 fax jobs. I don't have the foggiest idea how to make modifications to the script. I have tried several scripts but cannot get any of them working 100%. Our format is #@fax.domain.com.
Here are a couple of entries from my Done queue. Notice that the first job is going to an invalid number and the second is formatted correctly (I added the #s for security) but still does not go out.

56 F nobody 801####### 0:3 12:12 116 Busy signal detected; too
55 F nobody AvantGuard" 0:3 12:12 116 Busy signal detected; too

mail2fax.sh script we use to parse the incoming message

#!/bin/sh
#
# simple mail-to-fax utility using both faxmail and sendfax.
#
# - Lee Howard
#

#
# Mail addresses can be three ways:
# 1) us...@host.org
# 2) "User Name" <us...@host.org>
# 3) us...@host.org (User Name)
#
# in the latter cases, quotes may or may not be used,
# there may or may not be any User Name at all, and User Name
# may come before or after us...@host.org.
#
# We need to make sure we handle all these possibilities for
# both TO and FROM situations. Return-Path is different.
#

RANDOMFAX=/tmp/mail2fax.$$
mkdir $RANDOMFAX

cat >> $RANDOMFAX/_message_

# Uncomment the following three lines for debugging.
#set -x
#exec > /tmp/mail2faxlog.$$ 2>&1
#cp $RANDOMFAX/_message_ /tmp/mail2faxmail.$$

JOBID=`grep -e "^subject:" -i $RANDOMFAX/_message_ | sed q | sed 's/^[^:]*: *//g'`
TOLINE=`grep -e "^to:" -i $RANDOMFAX/_message_ | sed q`
FROMLINE=`grep -e "^from:" -i $RANDOMFAX/_message_ | sed q`
if [ "`echo $TOLINE | grep '<.*>'`" != "" ]; then
TONUMBER=`echo $TOLINE| sed -e 's/.*<\(.*[^@]*\)@.*>.*/\1/'`
else
TONUMBER=`echo $TOLINE| sed -e 's/^[Tt]o://g' -e 's/[ ]*\(.*[^@]*\)@.*/\1/'`
fi
if [ "`echo $FROMLINE | grep '<.*>'`" != "" ]; then
FROMPATH=`echo $FROMLINE| sed -e 's/.*<\(.*\).*>.*/\1/'`
else
FROMPATH=`echo $FROMLINE| sed -e 's/^[Ff]rom://g' -e 's/[ ]*\([^ ]*\).*/\1/'`
fi

cat $RANDOMFAX/_message_ | faxmail -v -N -T "$FROMPATH" | sendfax -vv -n -D -f "$FROMPATH" -i "$JOBID" -d $TONUMBER

rm -rf $RANDOMFAX

exit 0

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

Rycher

unread,
Mar 23, 2011, 1:23:08 PM3/23/11
to
I have a very similar(maybe the same) issue on Hylafax+ 5.2.5 on RHEL5
with a Postfix MTA and a very similar mail2fax.sh script with the same
#@fax.domain.com. I also have the Openoffice server installed in
hopes to convert MS document formats from the native
types(.docx,.xlsx,.doc,.xls,etc) to PDF and then to PS for fax
delivery.

Command-line sendfax works perfectly for this(works with
doc,docx,xls,etc). When the wrapper for the email-to-fax gateway is
incorporated and used, I get the same error that you get.

It appears that the 'TONUMBER' is getting blanked out in the process.
Unfortunately, I cannot get this process/script to generate any log
files on execution. I have set the logs to be writeable by both the
MTA user and the fax process executer with no luck.

Rycher

unread,
Mar 24, 2011, 6:43:08 AM3/24/11
to
Hey Scott...are you using Hylafax+?

I just figured out how to do this last night after a week of trying to
get it to work. This is my setup:
(The following instructions are for a Postfix/Hylafax+ email-to-fax
gateway with Microsoft document to fax/ps conversion.)
1. Hylafax+ 5.2.5.
2. Redhat Enterprise Linux 5.6, 32-bit, Real-Time kernel.
3. 8-port fax card.
4. Postfix MTA.

For an email-to-fax gateway(with Postfix anyway), no special
transitional scripts are needed between faxmail and sendfax.
The following modifications need to be done on for Postfix:

POSTFIX --
-----------------
1. Edit master.cf, add the following at the very bottom:
# EMAIL TO FAX GATEWAY SETTINGS
fax unix - n n - 1 pipe
flags= user=fax argv=/usr/bin/faxmail -d -n ${user}

2. Edit transport file, add the following at the very bottom:
# EMAIL TO FAX GATEWAY SETTINGS
fax.domain.com fax:localhost

3. Edit main.cf, add the following at the very bottom:
# EMAIL TO FAX GATEWAY SETTINGS
transport_maps = hash:/etc/postfix/transport
fax_destination_recipient_limit = 1

4. Run the following: postmap transport
5. Restart the Postfix service: service postfix restart
-----------------------------------------------


HYLAFAX+ --
----------------------
1. Install openoffice server. Run in headless mode (see Madhawa
Jayanath directions for 'runoffice', or create a startup system
script). This will be the engine for conversions of filetypes to PDF.
2. Install java and jodconverter.

2. Edit: /etc/hylafax/typerules, comment out the following:
#0 short 0xd0cf ps antiword -p letter -m 8859-1.txt %i > %o
#0 short 0xd0cf error Microsoft Word Document support not configured

3. Create file and add the following in /usr/bin/doc2ps:
#!/bin/bash
PATH=$PATH:/usr/local/bin:/usr/sbin:/usr/bin:/usr/bin/java/bin/
export PATH
java -jar /usr/src/jodconverter-core-3.0-beta-3/lib/jodconverter-
core-3.0-beta-3.jar -f pdf $1
gs -q -sPAPERSIZE=letter -dBATCH -dNOPAUSE \
-sDEVICE=pswrite -sOutputFile=- ${1%\.*}.pdf
rm -f ${1%\.*}.pdf
exit

**Note: The 'gs' program comes with Hylafax+ and is in fact used in
the Hylafax+ built-in conversion of PDF's to PS.**
**Note: This script becomes your conversion pass-thru, or
'transmission', if you will. Make the script executable**

4. Edit /etc/hylafax/hyla.conf, add the following at the very bottom:
MIMEConverters: /var/spool/hylafax/mimetype

5. Copy everything from /etc/hylafax/faxmail/* to /var/spool/hylafax/
mimetype/

6. Go to /var/spool/hylafax/mimetype/application/, create the
following file: office-converter.

7. In 'office-converter', add the following:
#!/bin/bash
MSDOCS=/usr/bin/doc2ps
$MSDOCS $1
exit

...this script will be the pass-thru for all MS Office mimetypes(it
can also be expanded to include image and text mimetypes if needed).
Make the script executable

8. Create mimetype symbolic-links to the 'office-converter' script:
cd /var/spool/hylafax/mimetype/application/
ln -s office-converter msword
ln -s office-converter vnd.ms-excel
ln -s office-converter vnd.ms-powerpoint
ln -s office-converter vnd.openxmlformats-
officedocument.wordprocessingml.document
...etc.

9. Send an email with a .docx attachment to your fax server. The
email address will have the following format
##########@fax.domain.address. The person who receives the fax will
get the .docx file in a fax/ps formatted document to their fax system.

0 new messages