Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
General
cancel
Showing results for 
Search instead for 
Did you mean: 

shell script using mailx or sendmail for multiple receiver ?

Matthew_50
Valued Contributor

shell script using mailx or sendmail for multiple receiver ?

Is there any sample script for deliver messages to multiple reciver using ksh ?

Thank you.
3 REPLIES
Dennis Handly
Acclaimed Contributor

Re: shell script using mailx or sendmail for multiple receiver ?

If you have a file with your message:
mailx -s "subject of message" user1@foo user2@foo < message-text-file
Bill Hassell
Honored Contributor

Re: shell script using mailx or sendmail for multiple receiver ?

And for large mailing lists, you can create a alias in /etc/mail/aliases with dozens of addresses:

biglist : me@com1.org, you@them.biz, us@abc.com

and for multiple lines, continue the line with a trailing \. Then run the command newaliases to update sendmail.

Now you can use mailx like this:

mailx -s "some subject" biglist < text-to-email


Bill Hassell, sysadmin
Elmar P. Kolkman
Honored Contributor

Re: shell script using mailx or sendmail for multiple receiver ?

According to the man page of mailx, you can even define groups/aliases in your own '.mailrc' file.
Every problem has at least one solution. Only some solutions are harder to find.