Messaging
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.