#!/bin/sh # # simple mail-to-fax utility using both faxmail and sendfax. # # - Lee Howard # - Django (Optionen für Empfangsbestätigung und Übertragungsmodus eingetragen) # # Mail addresses can be three ways: # 1) user@host.org # 2) "User Name" # 3) user@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 user@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 # Django : 2013-01-05 # Senden ohne Empfangsbestätigung (Parameter '-R' bei sendfax) #cat $RANDOMFAX/_message_ | faxmail -v -T $FROMPATH | sendfax -vv -n -D -f "$FROMPATH" -i "$JOBID" -d $TONUMBER # Django : 2013-01-05 # Senden mit Empfangsbestätigung (Parameter '-R' bei sendfax) #cat $RANDOMFAX/_message_ | faxmail -v -T $FROMPATH | sendfax -R -vv -n -D -f "$FROMPATH" -i "$JOBID" -d $TONUMBER # Django : 2013-01-06 # Senden mit Empfangsbestätigung und im Feinmodus bei der Faxübertragung (Parameter '-R' und '-G' bei sendfax) cat $RANDOMFAX/_message_ | faxmail -v -T $FROMPATH | sendfax -G -R -vv -n -D -f "$FROMPATH" -i "$JOBID" -d $TONUMBER rm -rf $RANDOMFAX exit 0