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

Philipp Schmidt philipp at ppc.in-berlin.de
Di Okt 9 19:18:11 CEST 2001


On Tue, 2001-10-09 16:37:30 +0200, Frank Reker <frank at reker.net>
wrote in message <20011009163730.A5550 at reker.net>:
> Am Tue 09. Oct 2001 12:39 +0200 schrieb Philipp Schmidt:
> 
> >On Tue, 2001-10-09 11:50:46 +0200, Alexander Saupe <alexsaupe at yahoo.de>
> >wrote in message <20011009095046.53533.qmail at web13507.mail.yahoo.com>:
> >> Hallo Liste,
> >> 
> >> Ziel: neu eingetroffene Faxe als Attachement per E
> >> Mail erhalten. Das script new_fax muss dazu umgeändert
> >> werden. 
> >> vorhandener Server: Suse 6.2, Pentium 133, 256 MB Ram
> >> als Mail- und Faxserver, läuft alles einwandfrei.
> >> 
> >> Frage:
> >> Langt die Hardware um aus dem g3 Format ein GIF oder
> >> PDF zu erzeugen?
> 
> Daf"ur reicht auch ein 386er!
> 
> >> Wo finde ich ein entsprechendes new_fax Script?
> >
> >mal sehen, hier sii meins (zum anpassen)
> >das Teil erzeugt png und druckt nochmal
> >
> [...]
> 
> Das Script gef"allt mir, ich w"urd nur auf jeden Fall die Zeile
> >TMPMAIL=$TMP/new_fax.$$
> ab"andern in 
> TMPMAIL=`mktemp $TMP/new_fax.XXXXXX`
> 
> Denn deine L"osung stellt eine Sicherheitsl"ucke dar.
> 
> Ferner kann man
> >trap "rm -f $TMPMAIL; exit" 0 1 2 15
> ersetzen durch 
> trap "rm -f $TMPMAIL" EXIT
> ist aber nicht so wichtig.
> 
die teile stammen noch aus 'ner urversion, die irgendwann mal mit
megetty kam.... hab da an anderen orten rumgewerkelt, hab's geändert
(thx;)


> >
> >        g32pbm -s $file | /usr/bin/convert pbm\:- png\:- \
> >	                | mmencode -b >> $TMPMAIL
> 
> BTW: convert kann auch direkt fax-formate (g3) verarbeiten:
> convert fax:$file png:- | ...

macht probleme, da die file je nachdem ob sie spar oder normalauflösing
haben sich unterscheiden, das packt convert leider nicht....

neue version attached, drucken kann man mit printer="" deaktivieren....

AVE!
  phils...

-- 
     PHILIPP SCHMIDT / phils - - + - - > philipp at ppc.in-berlin.de
     Phone: +49(30)66922513      ` - - > http://home.pages.de/~phils/
     --> ONLINE fuer Berlin & BRB? IN-Berlin! (info at in-berlin.de) <--

-------------- nächster Teil --------------
#!/bin/sh
#
# /usr/local/lib/mgetty+sendfax/new_fax
#
# new_fax <getty-exit-code> <fax-sender-id> <number-of-pages> <page> [<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 spinnaker.rhein.de>
# (c) 1999-2001 Philipp Schmidt <philipp at ppc.in-berlin.de> (modifications)
#
# $Id: new_fax.mime3,v 1.1 2001/10/09 19:09:08 gert Exp $
#

PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin

printer="stcolor"
ADMIN="faxadmin at ppc.in-berlin.de"	# mail address of fax administrator
			# 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 needs.

# thanks to Frank Reker <frank at reker.net>, the old way was insecure
TMPMAIL=`mktemp $TMP/new_fax.XXXXXX`
trap "rm -f $TMPMAIL" EXIT

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

# Create mail header:
echo "From: Fax Subsystem <$ADMIN>" > $TMPMAIL
echo "Subject: FAX from $SENDER with $PAGES pages" >> $TMPMAIL
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" >> $TMPMAIL
echo "" >> $TMPMAIL
echo "A fax from $SENDER was received at about" >> $TMPMAIL
echo "`date` consisting of $PAGES pages." >> $TMPMAIL
echo "The termination code of the fax program was $CODE." >> $TMPMAIL
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
do
    echo "--$BOUNDARY" >> $TMPMAIL
    echo "Content-Type: image/png" >> $TMPMAIL
    echo "Content-Transfer-Encoding: base64" >> $TMPMAIL
    echo "Content-Disposition: attachment; filename=\"`basename $file`\.png" \
                                                        	 >> $TMPMAIL
    echo "" >> $TMPMAIL

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

    echo "" >> $TMPMAIL

done

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

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



exit 0
-------------- nächster Teil --------------
Ein Dateianhang mit Binärdaten wurde abgetrennt...
Dateiname   : nicht verfügbar
Dateityp    : application/pgp-signature
Dateigröße  : 232 bytes
Beschreibung: nicht verfügbar
URL         : <https://mlists.in-berlin.de/pipermail/linux-l-mlists.in-berlin.de/attachments/20011009/231a8a7c/attachment.sig>


Mehr Informationen über die Mailingliste linux-l