Wegen die nette Unterhaltung bei
Postfix (oder "sendmail") kann man benützen für Serial-Mail. Hier mein Shellscript als "Freeware"!
Zwei Email in einer Textdatei mit Name "demo"
Code
jemand@t-online.de
Subject hier
Guten Morgen
Zeile 1
Zeile 2
@
somebody@web.de
This subject is about something else
How are you?
Another line
bla bla
bla bla
@
@
Alles anzeigen
Mein Shellscript "mats_mail"
Code
# SCRIPT TO SEND MAILS BASED ON FILE DATA FROM STANDARD INPUT
while true
do
# READ EMAIL ADDRESS
read address
if [ $? -ne 0 ]
then
echo The file not terminated with "@"
break
fi
if [ "$address" == @ ]
then
echo Normal end
break
fi
# READ "SUBJECT" FOR THE MAIL
read subject
if [ $? -ne 0 ]
then
echo EOF when "subject" was expected
break
fi
if [ "$subject" == @ ]
then
echo Terminator "@" when "subject" was expected
break
fi
# REPLACE ISO Latin 1 "UMLAUT"
subject=`echo $subject | sed 's/\xFC/ue/g' |sed 's/\xE4/ae/g' |sed 's/\xF6/oe/g'`
echo $subject
# READ THE FIRST LINE OF THE MAIL
read line
if [ $? -ne 0 ]
then
echo EOF when the first line of the message was expected
break
fi
if [ "$line" == @ ]
then
echo No message lines, processing terminated
break
fi
# REPLACE ISO Latin 1 "UMLAUT"
line=`echo $line | sed 's/\xFC/ue/g' |sed 's/\xE4/ae/g' |sed 's/\xF6/oe/g'`
# THE TEXT OF THE MAIL FIRST PUT IN TEMPORARY FILE
# "$line" instead of $line to preserve multiple blanks
# special characters are otherwise accepted as is without shell interference!
echo "$line" > tmp_file
while true
do
read line
if [ $? -ne 0 ]
then
echo EOF, mail body not terminated with "@"
break
fi
# "@" USED AS SEPERATOR BETWEEN THE MAILS
if [ "$line" == @ ]
then
break
fi
# REPLACE ISO Latin 1 "UMLAUT"
line=`echo $line | sed 's/\xFC/ue/g' |sed 's/\xE4/ae/g' |sed 's/\xF6/oe/g'`
echo "$line" >> tmp_file
done
# SEND THE MAIL
mail -s "$subject" "$address" < tmp_file
echo mail sent to "$address"
done
Alles anzeigen
Benützung