Click to See Complete Forum and Search --> : Mail All Users


*nixX
02-01-2005, 05:27 PM
I would think this should be easy but I can't find a clear cut answer.
I'm looking for a way to send a email to every user on my server quickly from the command line.

*nixX
02-02-2005, 08:19 PM
Well I ended up creating a little program that gathers the users mailboxes from /var/mail and sends mail to them all. Heres the script:

gatherusers

#!/usr/bin/sh
ls /var/mail > tmp
sed 's/^/mailit /' tmp > mail-allusers
rm tmp


mailit

#!/usr/bin/sh

echo "To:" $1 > TmpFile
echo "From: *nixX" >> TmpFile
cat message >> TmpFile
/usr/lib/sendmail -t < TmpFile


message

Attention:

Re: ADMIN MESSAGE

HOLA PEOPLE!

Thank You.


To use this, create all three files. Then run the gatherusers script. Next Edit the From: in mailit. Next edit message with what you want the message to read. Finally execute mail-allusers

**NOTE: You may need to change the path's in some of the scripts.**

Hope this helps someone!

nuttron
02-02-2005, 11:14 PM
well done , thanks for posting the outcome....too many dead end threads here...:D