Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I need to mail all users on my shared hosting platform. I need to be able to do this on a regular basis. Any thoughts?

share|improve this question

migrated from stackoverflow.com May 6 '10 at 22:46

This question came from our site for professional and enthusiast programmers.

    
Just all the local mail spools of all local users, or do they have external addresses you need to email? –  Daniel DiPaolo May 6 '10 at 20:41

1 Answer 1

Maybe something like:

echo "message" | mailx -s "notify" `grep -v '#' /etc/passwd | cut -d : -f 1 | sed 's/\(.*\)/&@localhost/' | tr  '\n' ' '`

Mails message with subject notify to all local users in the system. You can add this to cron(1) and use different mail addresses from a file:

echo "message" | mailx -s "notify" `cat emaillist.txt`
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.