Echo - Sending mail to multiple addresses


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Echo - Sending mail to multiple addresses
# 1  
Old 10-14-2010
Echo - Sending mail to multiple addresses

Hi,

If I want my script to send a mail to multiple recipients I can do the following:


if [ `echo $err_string1 | wc -c` -gt 1 ]
then
echo $err_string1 | mailx -s "UAT CPU ALERT"
1@email.com
echo $err_string1 | mailx -s "UAT CPU ALERT" 2@email.com
fi


Can this also be done something like:

if [ `echo $err_string1 | wc -c` -gt 1 ]
then
echo $err_string1 | mailx -s "UAT CPU ALERT"
1@email.com; 2@email.com
fi
# 2  
Old 10-14-2010
Yes to alternative 1.

No to alternative 2.

Most implementations of "mailx" only accept one recipient address.
That address could of course be a mailing list.

In unix the semi-colon character separates two commands on the same line. For some reason, Microsoft proprietary email software uses a semi-colon to delimit a list of email addresses whereas the rest of the industry uses a comma.


It is possible to present the mail recipient with a list of recipent addresses and CC addresses by using "mailx" "tilde" commands. You still need one "mailx" command per recipient.
This User Gave Thanks to methyl For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Sifting out mail addresses with grep and regex

Hi there from a newbie. So, I have this huuuge portion of mail addresses with names interlaced.. looks like: "name1" <mail1@domain1.com>, "name2" <mail2@domain2.com> ... Sometimes there are no names, just mailaddress. My thought was to use regex with grep. I saved the list in file ma and... (2 Replies)
Discussion started by: dr_xemacs
2 Replies

2. UNIX for Dummies Questions & Answers

Sending mail to multiple recipient added in a text file

I am trying to find a code that can help me mail to a list of recipients which are in a text file. Sample code $cat recipient.txt me@test.com me1@test.com me2@test.com I want a mailx step that can read contents of recipient.txt and mail to all the users. I don't want to use mails... (1 Reply)
Discussion started by: Gurkamal83
1 Replies

3. Shell Programming and Scripting

Mail sending with multiple attachement(pdf and csv) with html content from Linux

Hi, We have a requirement to send multiple attachment(pdf and csv) along with html content in a single mail. For that we are using uuencode. It is working for single pdf attachment and html content. But we are unable to send both pdf and csv attachment with html content. Below is the script.... (5 Replies)
Discussion started by: dholea
5 Replies

4. Red Hat

Problems sending mail: Difference between Mail and Mailx?

Whats the difference between mail and mailx? I'm trying to troubleshoot a problem where I can send mail from server A with this `echo $MESSAGE | mail -s "$SUBJECT" -r $FROM $RECIPIENTS` command but executing the same command from server B throws me this error (Both servers are RHEL) ... (1 Reply)
Discussion started by: RedSpyder
1 Replies

5. Shell Programming and Scripting

Extract e-mail addresses on a page

Hi I normally ask questions on coding but I think there is a code that can do this. I have regular text throughout my file and I want to extract all e-mail addresses from it (rather than going and searching each one). E-mails all have @ so I assume there is a way. Thanks Phil (6 Replies)
Discussion started by: phil_heath
6 Replies

6. Shell Programming and Scripting

sending multiple files along with mail message using uuencode

Hi, I have a requirement to send a mail with multiple files attached to it and along with the text message in the mail. I am trying sumthing like below but it only sends me the text message and no files attached to the mail. ---------------------------------------- ( uuencode file1... (1 Reply)
Discussion started by: sachinkl
1 Replies

7. Shell Programming and Scripting

Perl - match e-mail addresses in multiple files

Hi, I'm trying to write a script that will check multiple files in a directory (all the relevant filenames begin "TT04.NOTES") for e-mail addresses, and then print these addresses to screen with a count at the bottom. I'm a bit of a novice with Perl but thought it would be the best tool for the... (2 Replies)
Discussion started by: wf1974
2 Replies

8. Shell Programming and Scripting

Stop sending mail after certain number of mail

Hi guys... I am busy writing a script to notify me via an mail if my application is down. I have done that. Now I want this script to stop sending mails after five mails were sent but the script should keep on checking the application. When the application is up again that count should be... (5 Replies)
Discussion started by: Phuti
5 Replies

9. Shell Programming and Scripting

How can i send mail to multiple addresses in same domain in bash?

Suppose i have a txt file that is the list of the addresses,something like: lala0045 john james lala0234 george james and i want to send an email to lala0045@blabla.com and lala0234@blabla.com,the same domain...what is the exact syntax i should use in my script? there is a command... (10 Replies)
Discussion started by: bashuser2
10 Replies

10. UNIX for Dummies Questions & Answers

unix-mail to external websites/addresses

Hi all, I would like to know if I can send unix mail to 'external email addresses'. My unix server is leo@ABCcompany.com. I am able to send emails to firstname.lastname@ABCcompany.com. But, we have some email addresses in our team on our parent company's server - ex:... (2 Replies)
Discussion started by: Joy_K
2 Replies
Login or Register to Ask a Question