Script - mailer



This is the script which I wrote by someone's request, and it seems getting popular.
Please feel free to make a copy of it if you find it useful for you.
The script sends e-mail to group of people individually so that each person received the mail would think that it has been sent personally just for herself/himself. Also the mail won't have the long list of email addresses at the header.
You need two files to use it; one with list of addresses and one with message.
First, the address file is like this:
	bkim@cs.uml.edu	   "Dear Bo:"      bo kim 
anybody@somewhere "Ms. Anybody" friend
...
That is, each line consists of address, personal greeting, and any comment which won't appear in the mail message. Make sure to use '"' for personal greeting.
Second, the message file is the content of mail you want to send to group of people and can have any format you like.
If you name the address file and message file as addressbook and mymail, respectively, then the following will be the command to send mail:
       mailer mymail addresssbook 

Enjoy.




#! /bin/sh
# written by Bo-Kyoung Kim (Dec. 1997)

if [ $# -ne 2 ]; then
    echo 'Usage:  mailer  message_filename  address_filename'
    exit 1
fi

mesg_file=$1
addr_file=$2

lines=`wc -l $addr_file |awk '{print $1}'`
i=0
while [ $lines -gt $i ]
do
    i=`expr $i + 1`
    name=`head -$i $addr_file | tail -1 | awk '{print $1}'`
    if [ $name ]; then
        hi=`head -$i $addr_file | tail -1 | awk -F'"' '{print $2}'`
	echo $hi > tmp_file
	cat $mesg_file >> tmp_file
	mail $name < tmp_file
    else
        b=`expr $b + 1`
    fi
done
rm -f tmp_file
i=`expr $i - $b`
echo Sending $mesg_file to $i $addr_file members done.



Here is the postscript file for downloading.