Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send Message to all mailbox

Status
Not open for further replies.

Winux

MIS
Aug 23, 2002
14
CA
I'm new to sendmail, I was wondering is there a way to send a message to all the mail boxes?

Thanks
 
I can't really think why you would really want to do this, but this might work for you.

Code:
mail `grep 'sh$' /etc/passwd | awk '{split($0,a,":"); print a[1];}'`
<body text>
.
 
Jad

Thanks for your reply. Frankly speaking, I'm new to sendmail & Linux, only 2 mths exp. Is there a easier way to it? May be with some sort of mail client?

tks
 
if you know everyone on your system, then you could create a mailing list with everyones name in it (that was what the grep line above was for) then you could send messages to everyone.

--------------------------

grep 'sh$' /etc/passwd <-- this finds everyone in /etc/passwd that has a shell ending in 'sh', so csh, ksh, sh, bash, bsh ... etc. will be got. daemon, bin, sys, adm, lp etc will not be mailed.

awk '{split($0,a,&quot;:&quot;); print a[1];}' <-- get the first bit of the line before the ':' and output it.

mail is just the command line mail tool.

the best way to do this really is to have an up to date alias list in /etc/mail/aliases with a mailing list with all the users in it.

then when anyone emails the mailing list name it will get sent to all the users in the list.

it might be nicer to get away without sending mail to everyone if you can, putting messages in the message of the day (motd) if they log in, bulletin board systems for colleagues, or something similar.

sendmail doesn't automatically provide you with a way of mailing everyone, mainly because it doesn't know who &quot;everyone&quot; is.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top