Email --> Fax Gateway (mgetty+sendfax) ???

Email --> Fax Gateway (mgetty+sendfax) ???

Post by Brian Arno » Fri, 23 Jun 1995 04:00:00



I am wondering if there are any pre-built e-mail to Fax gateway tools
set up and ready to go. I realize with a little glue (like, for me, in perl)
that the mgetty+sendfax tools could construct one, but rather than re-invent
the wheel...

Thanx in advance...

Brian Arnold, MIS Director
LB&M Associates
Lawton, Oklahoma, 73501

--
Brian Arnold, MIS Director
LB&M Associates
Lawton, Oklahoma, 73501

 
 
 

Email --> Fax Gateway (mgetty+sendfax) ???

Post by Chris » Tue, 27 Jun 1995 04:00:00


: I am wondering if there are any pre-built e-mail to Fax gateway tools
: set up and ready to go. I realize with a little glue (like, for me, in perl)
: that the mgetty+sendfax tools could construct one, but rather than re-invent
: the wheel...

That would be VERY nice...

I've done similar, but with MUCH more troubles...

What I've done are:

1.      Have sendmail to add a "fax" delivery agent.

2.      Write a script for the delivery agent (using faxspool)

3.      Add a rule to sendmail and so it creates a pseudo-host as
        fax.your_host.domain and mail delivery to this host is correspondingly
        delivered by "fax" delivery agent.

4.      Some tweak with faxspool to allow "ALL" people to send fax, while
        still denying people who are explicitly defined in fax.deny.

So fax can be done by sending mail to:



have procmail to do the rest of the processing...

Chris

--
Chris Lo                                                            A___A  




 
 
 

Email --> Fax Gateway (mgetty+sendfax) ???

Post by Unix Consulti » Tue, 27 Jun 1995 04:00:00


Chris Lo (c...@hkucs92.air.org) wrote:

: Brian Arnold (arnol...@ernie.lbm.com) wrote:
:
: : I am wondering if there are any pre-built e-mail to Fax gateway tools
: : set up and ready to go. I realize with a little glue (like, for me, in perl)
: : that the mgetty+sendfax tools could construct one, but rather than re-invent
: : the wheel...
:
: ...
: So fax can be done by sending mail to:
:
: 12345...@fax.your_host.domain
:
: A better way that comes to mind is using fax@your_host.domain "addressing" and
: have procmail to do the rest of the processing...
:
: Chris
:
: --
: Chris Lo                                                            A___A  
: ch...@air.org                                                 ____ / o o \
: c...@HK.Super.Net                                          _/~____   =^= /
: Chris...@p90.f487.n700.z6.fidonet.org                      <______>__m_m_>

Like this? :

#!/usr/bin/perl
###########################################################
#
# @(#) mail2fax.pl - Convert an email message to a fax
#
# The mail message is expected at STDIN or in an optionally
#  specified file, the output will be written to a temp.
#  file and handed into the FAX system from there.
#
# 1.00 05-Jun-1995 TB   First version
###########################################################
#
# Configurable items
$FaxSpool = "/usr/local/bin/faxspool";
$MailCmd = "/usr/lib/sendmail";

###########################################################
# Constants
($ProgName = $0) =~ s%.*/%%;
$Version = "1.00";
$CopyRight = "(c) Copyright 1995 Thomas Bullinger";

###########################################################
# main function

# Get the input
@OriginalMail = <>;
chop (@OriginalMail);

# Let the actual work be done by a child process
if (fork) {
    exit 0;

}

#----------------------------------------------------------
# NOW WE ARE THE CHILD

# Preset some variables
$From = "";         # mandatory
$ReplyTo = "";      # optional
$FaxNo = "";        # mandatory
$FaxTo = "";        # optional, but nice to have
$FaxUser = "";      # optional (not checked)
$FaxPass = "";      # optional (not checked)

# Parse the mail
$InMailHeader = 1;
foreach $Line (@OriginalMail) {

    # Check header lines
    if ($InMailHeader) {

        # Check for the end of the mail headers
        if ($Line eq "") {
            $InMailHeader = 0;
            $InFaxHeader = 1;
            die ("ERROR: No sender address found\n")
                                    if (($From eq "") && ($ReplyTo eq ""));
        }
        elsif ($Line =~ /^From: /) {
            # Check for a "^From: " header
            ($Temp, $From) = split (/From: /, $Line);
        } elsif ($Line =~ /^Reply-To: /) {
            # Check for a "Reply-To: " header
            ($Temp, $ReplyTo) = split (/^Reply-To: /, $Line);
        }
    } else {

        if ($InFaxHeader) {
            # Check for the start of the FAX body
            if ($Line eq "") {

                # Do we have a fax number (at least) ?
                if ($FaxNo eq "") {
                    # Inform the original sender that the fax has been spooled
                    $From = $ReplyTo if ($ReplyTo);
                    $date = `date`;
                    open (MAILFILE, "| $MailCmd -t") || die ("ERROR: Can not notify requestor\n");
                    print MAILFILE "From: MAIL2FAX gateway (mail2fax)\n";
                    print MAILFILE "To: $From\n";
                    print MAILFILE "Subject: Re: Your FAX is rejected\n";
                    print MAILFILE "Date: $date\n";
                    print MAILFILE "Your fax request could not be granted because you didn't specify a fax number\n";
                    close MAILFILE;

                    die ("ERROR: No fax number found\n");
                }
                $InFaxHeader = 0;

                open (TEMPFILE, "> /tmp/mail2fax.$$.t") || die ("ERROR: Can not create temporary file\n");
            } elsif ($Line =~ /^Fax-No: /) {
                ($Temp, $FaxNo) = split (/^Fax-No: /, $Line);
            } elsif ($Line =~ /Fax-To: /) {
                ($Temp, $FaxTo) = split (/^Fax-To: /, $Line);
            } elsif ($Line =~ /Fax-User: /) {
                ($Temp, $FaxUser) = split (/^Fax-User: /, $Line);
            } elsif ($Line =~ /Fax-Pass: /) {
                ($Temp, $FaxPass) = split (/^Fax-Pass: /, $Line);
            }            
        } else {
            # Check for the start of the signature
            last if ($Line =~ /^--/);

            print TEMPFILE "$Line\n";            
        }   # end if $InFaxHeader
    }   # end if $InMailHeader

}

# Close the temporary file
close (TEMPFILE);

# Feed the temporary file into the FAX system
if ($FaxTo) {
    $FaxSendCmd = sprintf ("%s -D \'%s\' %s /tmp/mail2fax.$$.t",
                           $FaxSpool, $FaxTo, $FaxNo);

} else {

    $FaxSendCmd = sprintf ("%s %s /tmp/mail2fax.$$.t",
                           $FaxSpool, $FaxNo);
}

system ($FaxSendCmd);

# We don't need the temp file anymore ...
unlink ("/tmp/mail2fax.$$.t");

# Inform the original sender that the fax has been spooled
$From = $ReplyTo if ($ReplyTo);
$date = `date`;
open (MAILFILE, "| $MailCmd -t") || die ("ERROR: Can not notify requestor\n");
print MAILFILE "From: MAIL2FAX gateway (mail2fax)\n";
print MAILFILE "To: $From\n";
print MAILFILE "Subject: Re: Your FAX is spooled\n";
print MAILFILE "Date: $date\n";
print MAILFILE "Your fax request has been granted and the fax itself is in the send queue\n\n";
print MAILFILE "The fax will be send to $FaxNo\n";
print MAILFILE "The fax recipient is $FaxTo\n\n" if ($FaxTo);
print MAILFILE "The exact command to spool the fax on the local system was:\n";
print MAILFILE "$FaxSendCmd\n";
close MAILFILE;

exit 0;

###################################################################
# .procmailrc
###################################################################

PATH=$HOME/bin:/usr/bin:/bin:/usr/local/bin:.
MAILDIR=$HOME/Mail      # You'd better make sure it exists
DEFAULT=/usr/spool/mail/$LOGNAME
LOGFILE=$MAILDIR/from
LOGABSTRACT=YES
LOCKFILE=$HOME/.lockmail

###################################################################
# The fax server
:0 HB w
* ^Subject:[ ,\t]*FAX-REQUEST
|/usr/local/bin/mail2fax.pl
#|/usr/local/bin/mail2fax /tmp/FAX.$LOGNAME.t

###################################################################
# Anything that has not been delivered by now will go to $DEFAULT
# using LOCKFILE=$DEFAULT$LOCKEXT

 Name

    mail2fax - Convert a mail message to a fax and spool it

 Syntax

    mail2fax < mail-messsage

 Description

    mail2fax normally takes a mail message input and converts  it
    into a FAX. It also spools it via "faxspool".

    The first four lines of the mail text must contain:
    Fax-To: Name of the recipient
    Fax-No: FAX number of the recipient
    Fax-User: Username of the sender
    Fax-Pass: Password of the sender (not implemented yet)

    The next line of the text MUST be empty.

    Everything  up  to the last line of the text or the first oc-
    curence of two dashes ("--") make up the body of the FAX.

    Examples:

    Fax-To: John Smith
    Fax-No: 555-1212
    Fax-User: Joe Blow
    Fax-Pass: Password

    This is the body of the FAX.

    --
    Everything below the two dashes is ignored.

RETURN VALUES

      0    Everything went okay
      1    Output  could not  be  created
      2    No  output  file  was  specified
      3    No fax number was found

--
-------- Thomas Bullinger ------- Specializing in Linux systems --------
* Installation * Setup * Maintenance * Training * Software * Information
* Email: cons...@btoy1.rochester.ny.us    FAX: +1-716-377-6732
* WWW:   http://btoy1-gw.roc.servtech.com/~consult

 
 
 

Email --> Fax Gateway (mgetty+sendfax) ???

Post by Brian Han » Wed, 05 Jul 1995 04:00:00


: I am wondering if there are any pre-built e-mail to Fax gateway tools
: set up and ready to go. I realize with a little glue (like, for me, in perl)
: that the mgetty+sendfax tools could construct one, but rather than re-invent
: the wheel...

: Thanx in advance...

: --
: Brian Arnold, MIS Director
: LB&M Associates
: Lawton, Oklahoma, 73501

I fashioned a simple e-mail-to-fax gateway by creating pseudo-account
and having a .forward file send the inbound mail to the following
script (I used a pseudo-user instead of a simple alias because
I wanted a different UID running the script):

---------------------------------------------------------------------
#!/bin/sh

exec 2>> /tmp/faxmail.debug.$$
set -x
TMP=/tmp/fax.$$
TMP2=/tmp/fax2.$$

punt () {
        rm -f $TMP $TMP2
        exit 1

Quote:}

cat > $TMP
PHONE=`head -50 $TMP | grep ^Subject: | awk '{print $2}'`

exec < $TMP
exec > $TMP2

while :
do
        read LINE
        if [ -z "$LINE" ]
        then
                break
        fi
done

cat

/usr/local/bin/faxspool -f $SENDER $PHONE $TMP2\
        | mail -s "Faxspool output" $SENDER

rm -f $TMP $TMP2
exit 0

---------------------------------------------------------------------

This calls faxspool, which is part of mgetty+sendfax.
Works great.

I've also created an e-mail-to-pager gateway in case you are interested.
I use it with SkyTel's Nationwide Now service and an alphanumeric pager.

If I can be of any further assistance, please e-mail.

--

------------------------------------------------------------------------
*Nautix, Inc.                       http://www.veryComputer.com/~nautix

Internet and UN*X System Mgt, Training, Consulting       +1.707.427.2633

 
 
 

1. mgetty+sendfax printing incoming faxes to HP LaserJet

Hi, thanks for your answers.

#!/bin/bash

Yes here I mistyped but in my script it looks like:

When I use the first comand, its printing but the wrong resolution.

1.I took a look at /var/spool/fax nothing in here

2.I found other samples in /usr/share/doc/mgetty-1.1.25

3.I tried,
  printfax.ps from comand line >printfax.ps -h fnb*

  I get the error, image too large for page, rescaling to 0.340742

4.Than I tried new_fax.pbm to convert fax file and compress it, but nothing changed

5.I also put in the new_fax.lj to auto print but this script isn't working too.

6.I found info about scale and used:

the job was in queue for 10 min. and its printout was just one line

Any idea what I am doing wrong?

Thanks again

2. Printer: Canon BJC5000

3. how to view sendfax/mgetty faxes

4. Q: POSIX way to get # lines of terminal?

5. mgetty+sendfax, print incoming faxes to HP LaserJet (RedHat 7.0)

6. Downloading RPM's

7. POOR QUALITY of received faxes with mgetty-sendfax

8. WWDSI News (Developer's of SAINT)

9. mgetty+sendfax and USR V.FC DS fax don't cooperate

10. Fax with mgetty&sendfax

11. sending g3-fax using mgetty+sendfax with creatix144vfi

12. Faxing with mgetty+sendfax (.gs to .g3 translation?)

13. supra fax modem and mgetty+sendfax?