I have a list of mail ids in text file and want a ksh script that reads this text file and sends a mail to all mail ids with same subject line and content.
I am using UX-HP machine and KSH.
Thanks for help in advance!
I have a list of mail ids in text file and want a ksh script that reads this text file and sends a mail to all mail ids with same subject line and content.
I am using UX-HP machine and KSH.
Thanks for help in advance!
what is the format of the text file?
are the Ids on each line? csv?
txt file can be anything, I just have a list of mail IDs. not sure what format of file to put these mail IDs. but list may grow in future. so, option should be there to add mail IDs later to the file.
from the format i was trying to ask that you file contains the IDs like,
abc.123@domain.com,abc.123@domain.com,abc.123@domain.com
or
abc.123@domain.com
abc.123@domain.com
abc.123@domain.com
or
abc.123@domain.com|abc.123@domain.com|abc.123@domain.com
or even simply,
abc.123@domain.com abc.123@domain.com abc.123@domain.com
try respectively,
echo 'this is content' | mailx -s 'subject' $(cat file | tr ',' ' ')
or
echo 'this is content' | mailx -s 'subject' $(cat file | tr '\n' ' ')
or
echo 'this is content' | mailx -s 'subject' $(cat file | tr '|' ' ')
or
echo 'this is content' | mailx -s 'subject' $(cat file)
I have a text file mail_list.txt where mail ids are list one below the other
Ex:
#!/bin/ksh
sendm()
{
sendto="$1"
/usr/lib/sendmail -t -i <<EOF
Subject: some
From: some
To: $sendto
Maildata
EOF
}
##### main #####
cat somefile | while read addr
do
sendm "$addr"
done
More sendmail examples.