From: sher () altek ! com ! my (Sher)
To: tru64-unix-managers
Subject: SUMMARY: email to list of users
Date: Thu, 12 Jun 1997 01:59:30 +0000 [thread overview]
Message-ID: <96078613510404.tru64-unix-managers.marc@archive.invalid> (raw)
Hi all,
Thank you very much to the people who responded to my mail. I received a
few great replies before my own posting!! This group is great!
Anyway, sorry for delaying it, I've received such a great
script/ideas/solutions from the below people. I do received a word of
caution not to do email spamming kinda stuff. Actually I'm doing it to
invite a set of VIPs for our coming-launching-event (if you're in Asian
region, pls visit us at http://altavista.skali.com.my), and later to
some subscribed customers. Thanks guys! Makes my job really easy..and
enjoyable now.
Niels Kokholm <kokholm@math.ku.dk>
Lucio Chiappetti <lucio@ifctr.mi.cnr.it>
Michael C Taylor <mctaylor@mta.ca>
Cliff Friedel <cfriedel@jane.penn.com>
Steve Swinnea <swinnea@weiss.che.utexas.edu>
"Stephen B. Henry" <steve@headwaters.com>
Richard Eisenman <eisenman@tricity.wsu.edu>
Brian Sherwood <sherwood@esu.edu>
Yizhong Zhou <zhou@mathworks.com>
"Christopher L. Davis" <cld@prin.edu>
Mike Epstein <mjepst@hcs.harvard.edu>
Len Senetza <len@helix.net>
Gernot Salzer <salzer@logic.tuwien.ac.at>
Russell Johnson <rkj@beta.loyno.edu>
rioux@ip6480nl.ce.utexas.edu (Tom Rioux)
My posting
------------
> Hi gurus,
>
> I need to send email to about 1,000 email account of our customer.
> Usually I've to do it manually (and that is sending email one by one
up
> to about 1,000 to the customers - because I want to retain the 'from'
> and 'to' to the individuals). It takes me almost a day to complete it.
> Now I need send it again. The majordomo or any mailing list doesn't
fit
> my requirement. Is there any bots that can do this automatically
within
> a click away??
>
> regards,
> Sher.
>
The Solution
-------------
Basically all I need to do is to write a script that doing a 'loop while
reading a list of email address and mail it with a body'. A shell or
perl script will do...and I'm attaching most of them here for you to
choose.
You won't believe it how simple the scripts were! (except those few
perl script I received that I haven't had the chance to examine the
code..)
Ok here's the script;
**********from Niels Kokholm <kokholm@math.ku.dk>
#!/bin/sh
for receiver in `cat addr.txt`
do
echo next
mailx -s Subject $receiver < letter.txt
done
Here the receivers addresses are in addr.txt, one pr line and the text
of
the letter is in letter.txt.
**********from Lucio Chiappetti <lucio@ifctr.mi.cnr.it>
issue a command (csh) like :
foreach i ( `cat addr.list` )
/usr/bin/mailx -s "yoursubject" $i <pinco.txt
end
**********from Cliff Friedel <cfriedel@jane.penn.com>
#!/usr/bin/perl
##########################################################################
# massmail.pl
# By Cliff Friedel
# For Penncom Internet
# Usage:
# massmail.pl userfile text fromname
#
# userfile - list of users you wish to send mail to (just
username!)
# text - message you wish to send. (First line should have
Subject)
# fromname - who the message is from (just username!)
#
##########################################################################
#Array Initializer
$a = 0;
#open users file
open (INFO, $ARGV[0]) || die "Can't open users file!\n\n";
while ($info = <INFO>)
{
@list[$a] = $info;
$a++;
}
#reinitialize Array number
$a = 0;
#close the users file
close (INFO);
#Process list into something useable
chop @list;
#open the text file
open (TEXT, $ARGV[1]) || die "Can't open message!\n\n";
while ($intext = <TEXT>)
{
@text[$a] = $intext;
$a++;
}
#this gets the subject line and shortens the array by 1 so the subject
#line is not printed in the body
$subject = @text[0];
#close the textfile
close (TEXT);
#mail the text file to each person in the users list
foreach $list (@list)
{
open(MAIL, "|/usr/sbin/sendmail $list\@penn.com");
print MAIL "Reply-to: ",$ARGV[2],"\@penn.com\n";
print MAIL "From: ",$ARGV[2],"\@penn.com\n";
print MAIL "Subject: $subject\n\n";
foreach $text (@text)
{
print MAIL $text;
}
close (MAIL);
}
*********from Steve Swinnea <swinnea@weiss.che.utexas.edu>
you could make up a list of email addresses one-per-line
make a shell script:
while read i
do
echo $i
mailx -s "Here's a Message for You" $i < the.message.contents
done
and then run it with:
cat address.list | script
**********from Yizhong Zhou <zhou@mathworks.com>
foreach i (`cat users`)
Mail $i < message.txt
sleep 1
end
*********from Mike Epstein <mjepst@hcs.harvard.edu>
it would take about 2 minutes to write a perl script
the idea is
foreach (list of names goes here)
{
open (MAIL, "| /pathname/to/sendmail $_");
print MAIL <<EOF;
From: me
To: $_
Subject: whatever
the text of the message goes here.
EOF
close MAIL;
}
**********from Len Senetza <len@helix.net>
--- mail.all ---
#!/bin/tcsh
foreach n (`cat /etc/passwd | cut -d: -f1`);
echo Sending $1 to $n;
/bin/cat $1 | /bin/mailx -s "Scheduled Network Maintenance" $n;
sleep 5;
end;
--- end ---
use it like this:
# su - support
[support]> ./mail.all file_containing_mail_message
.
.
.
and wait...
***********from Gernot Salzer <salzer@logic.tuwien.ac.at>
#!/bin/sh
echo >mail2list.log
for addr in `cat addr.txt`
do
mailx -s 'subject text' $addr < contents.txt >>mail2list.log 2>&1
done
Make sure that "mail2list" has execute permission (otherwise enter
"chmod u+x mail2list"); and then execute "mail2list".
Error messages are logged to "mail2list.log".
**********from Russell Johnson <rkj@beta.loyno.edu>
heres a crude program that works for all in passwd file
#!/bin/sh
awk -F: ' $6 ~ /users/ { print $1, $5 } ' /etc/passwd > /rawlist
awk -F, ' $1 !~ /lp/ { print $1 } ' /rawlist > /list
for username in `cat /list | awk ' { print $1 } '`
do
mail $username < /msg
done
rm /rawlist
rm /list
msg is a file
if you put in From: ETC@ECTC.ETC
& Subject: WHATEVER
mail will include it in your msg.
**********from rioux@ip6480nl.ce.utexas.edu (Tom Rioux)
man mailx
I use someting like this:
echo "From: sysadmin@${node_name_full}\n" | \
cat - ${mail_newuser} ${log_dir}/${username}.user | \
mailx -s "${title_indiv}" ${mail_addr}
where ${node_name_full} is something like "global.ce.utexas.edu",
where ${mail_newuser} is a filename for the header of an e-mail,
where ${log_dir}/${username}.user is a filename of info for the user,
where ${title_indiv} is the subject, and
where ${mail_addr} is the users mail address.
You could write a script reading a file an do an e-mail to each line in
the file.
while read line
do
mailx -s "subject" ${line} <e-mail-file-name
done <e-mail-list-file-name
***********ok that's it! enjoy. again. thanks to whom responded.
regards,
--
Sher Khan
http://www.altek.com.my
http://altavista.skali.com.my "Make it so!"
reply other threads:[~1997-06-12 1:59 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox