# vi /etc/alias <---- edit alias file
add the following line at the bottom of the page
allusers: user1,user2
update the alias database
# newaliases
Using the above concept you can mail to all users of your office with following line in your
/etc/alias file:
When there are unlimited users
allusers: user1,user2,user3............. user500
But thats not a smart solution. Each time a new email user created and quit , you need to keep the /etc/alias database update.
1.Mail Forwarding with sendmail
To make your task easy, create an alais entry
# vi /etc/alias
allusers: :include:/etc/mail/allusers
# newaliases
# touch /etc/mail/allusers
Now each time before sending mail to alluser@yourdomain.com run the following command in your terminal
# awk -F: '$3 > 100 { print $1 }' /etc/passwd > /etc/mail/allusers
If you dont want to remember this long line you can make a binary file with this command and execute the file before sending mail to allusers@yourcompany.com
# vi /usr/bin/nameofusers
awk -F: '$3 > 100 { print $1 }' /etc/passwd > /etc/mail/allusers
2. Mail Forwarding with sendmail
# chmod 755 /usr/bin/nameofusers
Now each time before sending mail to alluser@yourdomain.com run the following command in your terminal
#/usr/bin/nameofusers
It'll send email to those users who are currently listed in /etc/passwd file.
1 comment:
nice post
Post a Comment