linux-l: mgetty / new_fax / neues Fax als GIF mail attachement

Alexander Saupe alexsaupe at
Di Okt 9 17:18:33 CEST 2001

Danke an euch alle für die Hilfe! Mir gefällt das
Script hier auch ganz gut, nur das Drucken wird nicht
benötigt. Weiß jemand wie genau das Script umgeändert
werden muss (ab # print & mail it: müssen wohl ein
paar Sachen gelöscht werden...)?

# /usr/local/lib/mgetty+sendfax/new_fax
# new_fax <getty-exit-code> <fax-sender-id>
<number-of-pages> <page> 
# This program is called by mgetty, when a fax is
received. It sends
# the fax as a multipart/mixed MIME mail to the
faxadmin ($ADMIN),
# where every fax page is attached as image/x-fax-g3
(the native
# received format, which is compact and which can be
viewed with the
# viewfax command). To view and print a page from your
mail reader add
# the following to your ~/.mailcap:
# image/x-fax-g3; viewfax -geometry +5+23 '%s';
test=test -n "$DISPLAY"
# image/x-fax-g3;; print=printfax '%s'
# You need the program mmencode for base64 encoding of
the fax data,
# which you will find in your metamail distribution.
# (c) 1997-1998 Roland Rosenfeld
<roland at>
#     1999-2001 Philipp Schmidt
<philipp at> (modyfied)
# $Id: new_fax.mime3,v 1.2 2001/10/09 12:10:08 gert
Exp $


ADMIN="faxadmin at localhost"	# mail address of fax
			# change this to your needs!

CODE="$1"		# getty exit code 
SENDER="$2"		# fax senders ID
PAGES="$3"		# number of pages
shift 3

TMP=/tmp		# temporary directory. change this to your

trap "rm -f $TMPMAIL; exit" 0 1 2 15

BOUNDARY="newfax-`date +%s`-$$"

# Create mail header:
echo "From: Fax Subsystem <$ADMIN>" > $TMPMAIL
echo "Subject: FAX from $SENDER with $PAGES pages" >>
echo "Mime-Version: 1.0" >> $TMPMAIL
echo "Content-Type: multipart/mixed;
boundary=$BOUNDARY" >> $TMPMAIL
echo "" >> $TMPMAIL

# Create first part of the mail (describing the fax):
echo "--$BOUNDARY" >> $TMPMAIL
echo "Content-Type: text/plain; charset=us-ascii" >>
echo "" >> $TMPMAIL
echo "A fax from $SENDER was received at about" >>
echo "`date` consisting of $PAGES pages." >> $TMPMAIL
echo "The termination code of the fax program was
echo "The pages are included below." >> $TMPMAIL
echo "" >> $TMPMAIL
echo "   Your Fax-Subsystem" >> $TMPMAIL
echo "" >> $TMPMAIL

# Add every page of the fax to the mail:
for file
    echo "--$BOUNDARY" >> $TMPMAIL
    echo "Content-Type: image/png" >> $TMPMAIL
    echo "Content-Transfer-Encoding: base64" >>
    echo "Content-Disposition: attachment;
$file`\.png" \
 	 >> $TMPMAIL
    echo "" >> $TMPMAIL

    export $file
 # print & mail it:
    if expr "`basename $file`" : "FAXn" >/dev/null
        # normal resolution
	( g32pbm -s $file | /usr/bin/convert pbm\:- ps\:- |
lpr -P$printer ; 
true) &
        g32pbm -s $file | /usr/bin/convert pbm\:-
png\:- \
	                | mmencode -b >> $TMPMAIL
	# fine resolution
        ( g32pbm $file | /usr/bin/convert pbm\:- ps\:-
| lpr -P$printer 
; true) &	
        g32pbm $file | /usr/bin/convert pbm\:- png\:-
	             | mmencode -b >> $TMPMAIL

    echo "" >> $TMPMAIL


echo "--$BOUNDARY--" >> $TMPMAIL

# Send out the created mail:
sendmail -f "$ADMIN" "$ADMIN" < $TMPMAIL

exit 0


Do You Yahoo!?
Es ist soweit: das Nokia Game beginnt. Sei bereit für das multimediale Abenteuer. Melde dich bis zum 3. November bei an!

Mehr Informationen über die Mailingliste linux-l