We help IT Professionals succeed at work.

Setting a allusers email

will_do
will_do asked
on
261 Views
Last Modified: 2013-12-16
Hi There
I need to setup a email that will email every user on the system
has anyone got any ideas how to do it

Phil
Comment
Watch Question

Top Expert 2005

Commented:
Well, you could create an alias that included all user names, but that gets very unwieldy for a large number of users. You could also create a list of users and use a shell script to read the list and send the emails, but then you need to keep the list up to date. The last way, which I use, is to use a perl script to walk the password file, skipping system and a few other accounts and mailing a message to all others.

I can't get to the perl code from where I am now, but I'll get it and paste it into a comment later this evening.

Author

Commented:
Thankyou
Top Expert 2005
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
thankyou
but how do i set it up
where do i put the script?
do i add a allusers account?
sorry i'm very new to linux

Author

Commented:
thankyou
but how do i set it up
where do i put the script?
do i add a allusers account?
sorry i'm very new to linux
Top Expert 2005

Commented:
Okay, open a new file named "mailer" and paste the perl code into it. Close the file and make it executable with "chmod +x mailer". If you only want to use it from one account, just leave "mailer" in that user's home dir, otherwise you could copy the file to someplace that multiple users can get to, like /usr/local/bin or /usr/bin.

To use it, create a file containing the message and invoke the utility like "mailer sender "The Subject" message-file".

Author

Commented:
Thanks jlevie once again
but i just get mailer command not found when i type in mailer sender

Top Expert 2005

Commented:
If you are in the directory that you've created the mailer script file in, it might be that the current directory isn't in your path. Try "./mailer sender "A subject" msg-file". If that fails, make sure that it's executable:

levie> ls -l mailer
-rwxrwxr-x   1 levie    staff        2211 Feb 29 17:09 mailer*

The "x"s above indicate executable mode for user, group, and other.

Author

Commented:
ok i think i have got it

but this comes up
[root@phil allusers]# mailer sender "The Subject" message"




and the > just keep coming until you use ctrl c

Top Expert 2005

Commented:
There's an extra " at the end of the line after message. There have to "s around the second argument as a subject will usually contain spaces.

Author

Commented:
cool thankyou i got it

Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.