Operating System - HP-UX
1819791 Members
3331 Online
109607 Solutions
New Discussion юеВ

mailx: multiple receiptants

 
SOLVED
Go to solution
Jeff Hagstrom
Regular Advisor

mailx: multiple receiptants

How do I send out an email to more than 1 email address with one command?
5 REPLIES 5
Jeff Schussele
Honored Contributor
Solution

Re: mailx: multiple receiptants

Hi Jeff,

Just keep entering recipients separated by spaces

cat filename | mailx -s "Subject here" user1@company.com user2@company.com user3@company.com

and on up to the command line limit.

HTH,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Sridhar Bhaskarla
Honored Contributor

Re: mailx: multiple receiptants

Hi,

You can seperate the mailids with a comma.

mailx -s "subject" mailid1,mailid2 < your_file

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Chris Vail
Honored Contributor

Re: mailx: multiple receiptants

I usually keep my email addys in a file separate from the script itself:
DATA=/path/resultsfile
MLIST=/path/filename
for ADDY in `cat $MLIST|grep -v #|awk '{ print $1}'`
do
cat $DATA|mailx -s "Subject" $ADDY
# alternative: send as attached file
uuencode $DATA $DATA|mailx -s "Subject" $ADDY

done

This lets non-root users add or subtract their name from the mailing list. This mailing list is in a common area available so anyone in the company can subscribe or unsubscribe. Samba/CIFS is handy for this.
A typical mailling list has a line or two of comments at the top (marked with a #) instructing the users to put their addys on a single line followed by a carriage return.


Chris
Victor Pavon
Advisor

Re: mailx: multiple receiptants

Chris s use of CIFS is great for dynamic group of emails. But if you are dealing with a static number of user s emails you can add entries in /etc/aliases file as:

# Local aliases
sysadmin : yourbox@domain.com, yourfriend@yahoo.com
backupadm : backupadmin@domain.com, yourbox@domain
root : yourbox@domain.com

Make sure you stop, re-start maild and you will be able to reach 2 or more people with:

mailx -s "subject" sysadmin < your_file

Regards,

Victor
twang
Honored Contributor

Re: mailx: multiple receiptants

Agree with Victor, you may setup alias using /etc/aliases.