#!/bin/csh
# sends the file "message" to all persons in "addresses"
echo -n 'File mit Nachricht: '     # File mit Nachricht
set message = $<
echo -n "subject: "
set subject = ($<)
echo -n 'File mit Adressen: '   # eine Adresse/Zeile, ohne Komma
set addresses = $<
echo -n 'Absendeadresse: '
set absender = $<

echo 'The following message:'
echo '------------------------------------------------------------------'
cat $message
echo '------------------------------------------------------------------'
echo 'has been sent to the following addresses:'

@ i = 1
@ j = 0
foreach user ("`cat $addresses`")  
  mailx -s "$subject" -r $absender $user < $message
  echo ${i}: $user
  @ i ++
  @ j ++
  if ($j == 50) then
    sleep 10   # gib dem sendmail Zeit
    @ j = 0
  endif
end

echo -n "Text und Liste loeschen (j/n) - "
set ant = $<
if ("+${ant}-" == "+j-") rm $message $addresses
