Mail to multiple reciepent

Hi,

I have tried following command to send mail to a single user.

cat mail_body_file.txt | mail -s "This is subject" mail_ID@somedomain.com
What should I do to send a mail to number of Persons by including their mail ids in To and Cc field.

Create file for To and CC email list.
e.g
ToList.txt file content
mail_ID@somedomain.com, mail_ID1@somedomain.com, mail_ID2@somedomain.com

CCList.txt file content
mail_ID3@somedomain.com, mail_ID21@somedomain.com, mail_ID22@somedomain.com

echo "From: $LOGNAME\nTo: `cat ToList.txt`\nCc: `cat CCList.txt`\nSubject: $SUBJECT\n" > ${Mail_File}
echo "${Email Body}\n Regards,\n$LOGNAME" >> ${Mail_File}
/usr/lib/sendmail -t -oi < ${Mail_File}

some times comma separated email list doesn't work, in such cases use ";" as email separator.

--Manish Jha.

Hi,

Thanks for the help.
Sorry but I am not getting what is that {$Email_body}. It is a text file or a variable which is containing the mail body.

Please clarify the doubt, it will help me a lot.

use mail -c to send carbon copy

mail -s "Hello" -c him_cc@domain.com him_to@domain.com

you can use comma if you want to send to many users

$Email_Body is a variable which contains the body of the email. You could write email after Subject:,or you could have a file which you have to cat(like i did for 'To and Cc' list) or you could print value of the variable(echo "${Email Body})

--Manish