Great Circle Associates Majordomo-Users
(October 1996)
 

Indexed By Date: [Previous] [Next] Indexed By Thread: [Previous] [Next]

Subject: Re: MASS e-mailings
From: Jason L Tibbitts III <tibbs @ hpc . uh . edu>
Date: 10 Oct 1996 16:21:31 -0500
To: Rob Edwards <rob @ venus . net>
Cc: Majordomo-users @ GreatCircle . COM
In-reply-to: Rob Edwards's message of Thu, 10 Oct 1996 10:05:29 -0400 (EDT)
References: <199610101405.KAA29765@venus.net>

>>>>> "RE" == Rob Edwards <rob@venus.net> writes:

RE> Have got the latest version of majordomo running on my system, and it
RE> works great.  The problem is, we want to send e-mail to ALL our users.
RE> I wrote a perl script that pulls all the user ID's greater than UID 99
RE> and puts them in a file that looks like the majordomo listname file.  I
RE> created a majordomo mailing list and all the aliases neccessarry.

Have your outgoing alias point at a script like the following.  This
doesn't generate a file, it generates the address list on the fly and sends
the message out to sendmail.   If you still get errors because of the
system command being too long, it's a simple matter to split the list into
smaller chunks.  There's little need for bulk_mailer or the like, because in
this case the users are local (assuming that you have few users that
forward their mail all over the place).

#!/usr/local/bin/perl5 -w
#
# mailall
#
# sends mail to all users on this host.  verifies that the user is really
# a user by checking uid, shell, and login name.  allows us to send mail
# to, for example, "allusers@mother.cs.colorado.edu" and delievers that
# mail to all the "real" people on that machine.
#
# requires a line in /usr/lib/aliases like:
# allusers: "|/usr/local/bin/mailall"
#
# Originally By: davewood@cs.colorado.edu
#     October 15, 1992
# Hacked, mangled, and rewritten by
#     Jason L. Tibbitts <tibbs@hpc.uh.edu>


# Set this for testing
$DEBUG = 0;

# Ignore all users with IDs less than this
$MIN_ID = 1000;

# Where to find list of shells
$ETC_SHELLS = "/etc/shells";

# Where to find the list of accounts
$ETC_PASSWD = "/etc/passwd";

# These users will not be sent mail
@nomail = qw(
	     dumpuser
	     flacs
	     fec
	     help
	     nobody
	     noacess
	     tester
	    );

# Grab the list of valid shells; users without a valid shell will get no
# mail
open(SHELLS,$ETC_SHELLS) ||
  die("Can't open list of valid shells: $ETC_SHELLS, $!, stopped");
@shells = <SHELLS>;
close SHELLS;

# Go through the password file and find real users
open(PASSWD,$ETC_PASSWD) || die ("Can't open password file: $ETC_PASSWD: $!, stopped");
foreach (<PASSWD>) {
  ($login,$dummy,$uid,$dummy,$dummy,$dummy,$shell) = split(/:/);
  push(@mailto,$login) if ($uid >= $MIN_ID &&
			   grep(/^$shell$/,@shells) && 
			   $shell !~ /^$/) &&
			     !grep(/^$login$/,@nomail);
}
close PASSWD;

if ($DEBUG) {
  print "Will send mail to these users:\n";
  foreach (@mailto) {
    print "$_\n";
  }
  exit 0;
}

# Dump standard input into a message sent to all valid users
open (MAIL,"|/usr/lib/sendmail @mailto");
foreach (<STDIN>) {
  print MAIL;
}
close MAIL;

-- 
      Jason L. Tibbitts III - tibbs@uh.edu - 713/743-8684 - 221SR1
System Manager:  University of Houston High Performance Computing Center
                1994 PC800 "Kuroneko"      DoD# 1723


References:
Indexed By Date Previous: Moderation with Offline Readers
From: wmcguire@cybercom.net (Wayne McGuire)
Next: Re: regx 's in restrict post
From: Jason L Tibbitts III <tibbs@hpc.uh.edu>
Indexed By Thread Previous: Re: MASS e-mailings
From: Chris Knowles <cknowles@redeemer.on.ca>
Next: unknown mailer error 139
From: "Boris Yazlovitsky" <boris@lovecraft.amd.com>

Google
 
Search Internet Search www.greatcircle.com