[ale] limiting access to e-mail aliases

Norbert Crettol nc at omedia.ch
Sat Dec 21 05:30:11 EST 1996


This is a script somebody put on this list (or on Linux-ISP at Lightning).

I use it and it works great. You can choose the group you want to mail to 
or even choose an UID range. You have to edit "Subject" on the last line 
(or make a constant of it). Maybe I've changed something, I don't 
remember. Apologies to the author if so.

Norbert

---- starts here -------------------------------------------------
#!/usr/bin/perl
#
# @(#) mail.all - Kent L Claussen
# v1.0 1996-02-27
# Mail to all users with a UID within the given limits.
# Go thru the /etc/passwd file to garner a list of users.
#
# Copyright 1996 by Kent L Claussen.  All rights reserved.
# Gnu license privileges granted.
#
# Real users start with the MIN UID and end with the MAX UID
# ----------------------------------------------------------
#
$UID_MIN = 500;
$UID_MAX = 9999;
$GID = 100;                         ### I might've added this (HSO)

if ($#ARGV != 0) {
    print "$0: Wrong number of arguments
    Usage: mailall FileNameToSendToAll\n";
    exit 1;
}

if (! -e $ARGV[0]) {
    print "File $ARGV[0] doesn't exist!\n";
    exit 2;
} else {
    if ((! -T $ARGV[0]) || (-z $ARGV[0])) {
        print "File $ARGV[0] is not a mailable file\n";
        exit 2;
    }
}

# Process the password file and keep the real users
while (($name, $passwd, $uid, $gid, $quota, $comment, $gcos, $dir, $sh)
      = getpwent) {
    next if ($uid < $UID_MIN);
    next if ($uid > $UID_MAX);
    next if ($gid != $GID);         ### Probably this one too (HSO)
    $Name{$name} = $gcos;
    if (defined $FullName{$gcos}) {
        print "*** Duplicate full name found for \'$FullName{$gcos}\'
        a
\'$name\' = \'$gcos\'\n";
    } else {
        $FullName{$gcos} = $name;
    }
}

# Process the built up list of users and send them mail
foreach $key (sort(keys %Name)) {
    &SendMail($key, $Name{$key});
}

sub SendMail {
    local ($User, $FullName) = @_;
    print "Sending mail to ", $User, " (", $FullName, ") ", "\n";
    system("/bin/mail -s 'Subject' $User <$ARGV[0]");
}
------ end here ---------------------------------------------------

-----------------------------------------------------------------
Omedia sa              Av. de la Gare 38          CH1920 Martigny
-----------------------------------------------------------------
Norbert Crettol                                 Internet services
nc at omedia.ch                                  connexions, conseil
++41 27 722 04 50     http://www.omedia.ch        creation de Web
-----------------------------------------------------------------

On Fri, 20 Dec 1996, Juan Bou Riquer. wrote:

> Hello, I use the next scrip to send mail to every mailbox in my system, it
> is very easy to implement and you can chmod 744 to be run only by root, I
> have the script at /root
> 
> #! /bin/sh
> cd /var/spool/mail
> for i in *
> do
> mail -s "Aviso Importante" $i < /root/mensaje
> sleep 10
> done
> 
> > 
> > Jon-Michael J. DeBona wrote:
> > > 
> > 
> > There are a few ways. You can make it a mailing list with
> > Majordomo and make the list moderated. That would be simplest.
> > You can also send the mail manually, setting the from and reply-to
> > with something that won't work. The mailiing list is the easiests
> > to do and to maintain.
> > 
> > Hope this helps.
> > 
> > 
> > 
> > Alexei
> 






More information about the Ale mailing list