Defcon-1-Logo

           [Home]    [FBSD Articles]    [Scripts Corner]    [Contribute]    [Search]    [FBSD Links]    [Files]

About Us

FreeBSD Articles
  *Hardware
  *Networking
  *Security
  *Software
  *X Windows


Files / Scripts
Newbies Corner
Tech. Talk
Tips and Tricks


FreeBSD Links

Articles in other
Languages :
  *French Articles
  *Spanish Articles

Want to Help ?
 
   Click Here

Email Users5

Search:
 

 


FreeBSD Search:


 

 

Powered-By-Apache-Logo

E-mailing all users on a system

 Several people have asked me before the easiest way to email all users on
there mail server, particaly ISP's (Service announcements etc.)

There are several methods, including qpoppers built in bulletin feature,
but my favourite is my method which I have show below.

To get it working, execute the following commands below as root:


1) awk -F: '$3 > 100 { print $1 }' /etc/passwd > /etc/mail/allusers

2) echo "allusers:  :include:/etc/mail/allusers" >> /etc/aliases ; newaliases

3) echo "#\!/bin/sh" > /etc/periodic/daily/350.allusers

4) echo "awk -F: '$3 > 100 { print $1 }' /etc/passwd > /etc/mail/allusers" >> /etc/periodic/daily/350.allusers

5) chmod 0755 /etc/periodic/daily/350.allusers


What it does
===========


The first line parses /etc/passwd, and extracts a list of usernames with
a UID greater than 100 and dumps them into the file /etc/mail/allusers.

The second entry then creates an alias called "allusers", which is based
on the file /etc/mail/allusers, and runs newaliases to update the aliases
database.

The next 3 lines create an entry in /etc/periodic, so that the list will
be updated each morning at 2am.

You use this script by sending an email to "allusers@hostname".

This will then suck in the usernames from /etc/mail/allusers and
email everyone on the system.

Have fun!

Sparc
jamie@jamiesdomain.org.uk
 

Email Us

ghostrdr@defcon1.org

This site cannot be duplicated without permission

© 1998 - 2010 Defcon1, www.defcon1.org. Copyrights for all materials on this web site are held by the individual authors, artists, photographers or creators. Materials may not be reproduced or otherwise distributed without permission of www.defcon1.org and the content's original author.