<<< Date Index >>>     <<< Thread Index >>>

Re: I don't want to send spam but can mutt do this?



On Mon, Dec 12, 2005 at 05:17:55PM +0100, Stephan Seitz wrote:
> On Mon, Dec 12, 2005 at 05:00:13PM +0100, Daniel Hertrich wrote:
> >Is there a way to let the for loop read a file with a list of addresses 
> >(one address per line), instead of listing the addresses all in the 
> >script?
> 
> Of course.
> 
> [...]
>
> stse@osgiliath:~> for i in `cat addresses`; do echo $i;done

Useless use of cat.  Try:

while read line ; do echo $line; done < somefile

At any rate, the following should be a workable script for the OP to
test out and with which he can play around.

---------------cut here------------------------------------
#!/usr/bin/bash

# Automagic mail processing with mutt
# See http://www.tldp.org/LDP/abs/html/index.html

# Sanity checks, error handling and Yes, No, Are You Sure?, Are You
# Really Sure?, and Are You Really REALLY SURE? prompts are left as
# an excercise for the reader.

subject='Testing Automagic Mail'
message="$HOME/automagic-message"
addresslist="$HOME/automagic-addresslist"
messagecount=1

error_log='/dev/null'
exec 2>>$error_log         # Never let errors spoil a script

# -- delete this section when done testing -----------------
fortune > $message || echo 'Have a nice day!' > $message

cat <<-EOF > $addresslist
Some Name 1 <user1@localhost>
Some Name 2 <user2@localhost>
Some Name 3 <user3@localhost>
Some Name 4 <user4@localhost>
EOF
# -----------------------------------------------------------

echo "Processing messages ..."

while read address ; do
    echo -en "   Message $messagecount \t: $address ... "
    mutt -s "$subject" "$address" < $message
    if [ $? -eq 0 ] ; then 
        echo 'done.' ; else
            echo 'Oops!!!'       # return code of 257 ?
    fi
    (( messagecount += 1 ))
done < $addresslist

---------------cut here------------------------------------

Have fun.

PS.  My apologies, Stephan, for hitting the 'r' instead of the 'L'.

-- 
George