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

multiple mail sending with bash script



Hi everyone && happy new 2008.
I will solve the following task but actually I'm unable to do it:
Every end of the month I send about 200 invoices to their respective 
recipients, sending them as e-mails with its own attachment using a win smtp 
server (blat).
For various reasons I want to replace such system and make the same task with 
mutt, using bash scripting on Linux.
I've tried to comply this using a ASCII text file named "test.txt" having one 
row per recipient in the format

mutt -s [subject(1)] -a [file attachment(1)] -i [txt file as message body] 
[recipient address(1)]
mutt -s [subject(2)] -a [file attachment(2)] -i [txt file as message body] 
[recipient address(2)]
.
.
mutt -s [subject(n)] -a [file attachment(n)] -i [txt file as message body] 
[recipient address(n)]

and a bash script named "test" like this:

!#/bin/sh
FILE="test.txt"
while read line; do
    `$line`
done < $FILE

When running the "test" script, it ends very early with no warnings: only the 
first message is dispatched, the others are ignored at all.

Another trial was a text file named "test2.txt" having one row per recipient in 
the format
subject(1)^name_file_to_attach(1)^recipient_address(1)
subject(2)^name_file_to_attach(2)^recipient_address(2)
.
.
subject(N)^name_file_to_attach(N)^recipient_address(N)

and a new bash script named test2 like this:

#!/bin/sh
FILE="test2.txt"
FS="^"
while read line
do
    F1=$(echo $line|cut -d$FS -f1)
    F2=$(echo $line|cut -d$FS -f2)
    F3=$(echo $line|cut -d$FS -f3)
    /usr/bin/mutt -s " " $F1 -i " " [body file text to include] -a " " $F2 " " 
$F3
done < $FILE

When running "test2" I have various errors but to cut short a long story it 
doesn't work.
My experience lacks for sure: is there anyone here who can help me ?

--
regards,
Alessandro

-- 
Are we headed for a recession? Read more on the Money Portal
Mail.com Money - http://www.mail.com/Money.aspx?cat=money