LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-29-2013, 01:45 PM   #1
ajayram_arya
LQ Newbie
 
Registered: Aug 2011
Posts: 2

Rep: Reputation: Disabled
Shell script to send multiple recipiants


Need help in a script . Newbie on scripting

I want to send a mail from unix to multiple recepients.
We can do that by using

/opt/csw/bin/mpack -s "test message " <path/file> user1@example.com user2@examle.com.

Which will send to both recipients listed in the mail as well both address are shown in the mail . I want to create a distribution list and use that list to send to all the recipients and they all should be displayed in a mail .
 
Old 01-29-2013, 04:51 PM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: Sutton, MA. USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu
Posts: 4,101
Blog Entries: 10

Rep: Reputation: 1524Reputation: 1524Reputation: 1524Reputation: 1524Reputation: 1524Reputation: 1524Reputation: 1524Reputation: 1524Reputation: 1524Reputation: 1524Reputation: 1524
I was thinking of two ways, however one applies, but I'll explain.

You can use a loop and open a reference file which has line by line user emails and the loop iteratively calls /opt/csw/mpack with the last argument substituted as you read the reference file.

The one that applies would be that you have a file which has one line, space delimited user emails, no loop and you merely use the entire contents of that file in a single substitution for one call to /opt/csw/mpack. The reason would be so that all recipients would see the full list of other recipients, as you've said here.

A caution is that if that list of recipients becomes really large, it could cause the command to be too long for your shell.
 
1 members found this post helpful.
Old 01-29-2013, 05:07 PM   #3
ajayram_arya
LQ Newbie
 
Registered: Aug 2011
Posts: 2

Original Poster
Rep: Reputation: Disabled
[solved]

Thank you rtmistler.

Here is the solution i found

/opt/csw/bin/mpack -s "test message " <path/file> `cat <distributionlist.txt>`

All recipients would see the full list of other recipients

If we dont want that way we can use the for loop sending individually
 
Old 01-29-2013, 09:33 PM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,604

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
A better way is to use aliases. A mail alias can be a list of email addresses, then you just send it to the alias name.

It does depend on your mail server to handle aliases.

It is much more efficient as the client mailer only has to deal with one address, and the mail server can batch as many of the recipients together into one connection to a remote server. Also, you can specify the address as a BCC and no one gets to see the list.
 
Old 01-29-2013, 09:36 PM   #5
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Distribution: UBUNTU 5.10 since Jul-18,2006 on Intel 820 DC
Posts: 806

Rep: Reputation: 186Reputation: 186
Also "mpack" may have a -b option to send in bcc mode. I know that "mailx" does.

OK
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How to send a mail using shell script gajananh999 Linux - Newbie 2 11-29-2012 02:55 AM
send email to server to start shell script bic Red Hat 5 12-04-2009 10:06 AM
Runs Multiple shell script inside a main script using crontab srimal Linux - Newbie 4 10-22-2009 07:19 PM
write a shell script to send email yenonn Programming 4 02-11-2005 11:06 PM
sendmail won't send from shell or php script dmedici Linux - Software 2 08-24-2004 04:15 PM


All times are GMT -5. The time now is 05:14 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration