Mail to multiple reciepent


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Mail to multiple reciepent
# 1  
Old 11-01-2006
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.
# 2  
Old 11-01-2006
use below code

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.
# 3  
Old 11-02-2006
Mail to multiple reciepent

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.
# 4  
Old 11-02-2006
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
# 5  
Old 11-02-2006
$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
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Mail command --> send multiple attachments

Hi, i try to send two (multiple) files by the mail-console-command mail -s TEST -a f1.pdf f2.pdf n.ame@ms123.de but it doesn't work. can someone give me a hint? Thanks in advance, IMPe (2 Replies)
Discussion started by: IMPe
2 Replies

2. Shell Programming and Scripting

Send a mail to multiple users

I have a file 1.txt which has 3 mail ids as below: Maillist=abc@gmail.com def@gmail.com rcg@gmail.com Now I want to write a script which will read this file and send the mail to all the users present in this file. (6 Replies)
Discussion started by: Vivekit82
6 Replies

3. Red Hat

How to send mail with multiple attachments?

We don't have uuencode installed in our machines..... Please tell me how to send mail with multiple attachments ??? URGENT !!!!! Please tell me using command line (or) scripts.......... please...... Thanks in Advance.... (1 Reply)
Discussion started by: vamshigvk475
1 Replies

4. Shell Programming and Scripting

Multiple files in one mail

Hello I'm using mail in liux to send files to users is there a way I can send multiple file withing one mail now I can send one file per mail mail -s "subject" user@domain.com < /var/file i have two more files to send file2 and fil3 but i want them to be in one mail ... (3 Replies)
Discussion started by: Sara_84
3 Replies

5. Shell Programming and Scripting

Problem with multiple mail attachments

Hi everyone... I am facing problem with the multiple mail attachments. cd /work/mohan/pi_log/ mail_file='uuencode ahmedabad.csv ahmedabad.csv ; uuencode ahmedabad_devrpt_20110530.csv ahmedabad_devrpt_20110530.csv' ( $mail_file ) | mailx -m -s"test" domain@website.com its giving me error... (1 Reply)
Discussion started by: mohanm
1 Replies

6. Shell Programming and Scripting

How to send mail with multiple files attached?

Hi, I would like to send a mail with multiples files attached. Until now i was doing a "find" and then a "tar" of the text files. As I need to be able to read them on a mobile device such as Blackberry for instance, i would like to send them in one single mail, but without taring them. is... (2 Replies)
Discussion started by: Pierrito
2 Replies

7. Shell Programming and Scripting

e-mail with multiple binary attachments!

Hi, I have to send email from UNIX with multiple excel attachments and the sender name needs to be customized (sender name need not to be UNIX user). I have checked many ways from this forum and other sources. But, nothing did work for me. Please help me! thanks, Raja. (1 Reply)
Discussion started by: smr_rashmy
1 Replies

8. UNIX for Dummies Questions & Answers

Search for multiple strings and mail accordingly

Hi, I need to find if there is any error in the last few lines of the log file and send a mail accordingly.For example, Following errors can be logged in the log file. ERR_1="DB Connection not established" ERR_2="Server Unloading" I need to find if these errors are found in the log file and... (3 Replies)
Discussion started by: AnneAnne
3 Replies

9. AIX

Not able to send out multiple file in mail

Hi All, I have AIX 5.3 server. I am not able to transfer multiple file in mail but I can send one file at a time. the following command I am using to send multiple file mail -s 'PICS EXP RATE Logs' lger@nd.com < /data02/transfer/*_experience_rate_log.txt but this not working. i can send... (2 Replies)
Discussion started by: vishalpatel03
2 Replies

10. UNIX for Dummies Questions & Answers

How to send mail to multiple users ???

Hi All, How to send mails to multiple users using a single mailx command. Urgently require help Thanks in advance Rgds Arunava (3 Replies)
Discussion started by: arunava_maity
3 Replies
Login or Register to Ask a Question