Mailing from a script - 2

Edgar Allen era at sky.net
Wed Jun 20 00:27:51 CDT 2001


Forwarded message:
>
>Is there a way to send a mail message to a bunch of people who's mail
>addresses are maintained in a file?
>
>Thought of a shell or perl script that would open the file and, for each
>iteration of a loop, assign the line content to a variable and issue a mail
>command, putting their address in the destination field.  Then assign the
>next line (address) to the variable and loop again, until EOF.
>
#!/bin/bash
# Send email to a list of names:
#  Useage:  $0 "subject of msg" pathname2msgBody recipientFile
name=nobody
while [[ "$name" != "" ]]
do
if [[ "$name" != "nobody" ]] ; then
    fastmail -f $LOGIN -s "$1" $2 "$name"
    read name
done <$3

This assumes one recipient per line in the recipientFile and queues
individual messages so that delivery will be as fast as possible.




More information about the Kclug mailing list