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_at_math.ku.dk>
Lucio Chiappetti <lucio_at_ifctr.mi.cnr.it>
Michael C Taylor <mctaylor_at_mta.ca>
Cliff Friedel <cfriedel_at_jane.penn.com>
Steve Swinnea <swinnea_at_weiss.che.utexas.edu>
"Stephen B. Henry" <steve_at_headwaters.com>
Richard Eisenman <eisenman_at_tricity.wsu.edu>
Brian Sherwood <sherwood_at_esu.edu>
Yizhong Zhou <zhou_at_mathworks.com>
"Christopher L. Davis" <cld_at_prin.edu>
Mike Epstein <mjepst_at_hcs.harvard.edu>
Len Senetza <len_at_helix.net>
Gernot Salzer <salzer_at_logic.tuwien.ac.at>
Russell Johnson <rkj_at_beta.loyno.edu>
rioux_at_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_at_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_at_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_at_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>)
{
_at_list[$a] = $info;
$a++;
}
#reinitialize Array number
$a = 0;
#close the users file
close (INFO);
#Process list into something useable
chop _at_list;
#open the text file
open (TEXT, $ARGV[1]) || die "Can't open message!\n\n";
while ($intext = <TEXT>)
{
_at_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 = _at_text[0];
#close the textfile
close (TEXT);
#mail the text file to each person in the users list
foreach $list (_at_list)
{
open(MAIL, "|/usr/sbin/sendmail $list\_at_penn.com");
print MAIL "Reply-to: ",$ARGV[2],"\_at_penn.com\n";
print MAIL "From: ",$ARGV[2],"\_at_penn.com\n";
print MAIL "Subject: $subject\n\n";
foreach $text (_at_text)
{
print MAIL $text;
}
close (MAIL);
}
*********from Steve Swinnea <swinnea_at_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_at_mathworks.com>
foreach i (`cat users`)
Mail $i < message.txt
sleep 1
end
*********from Mike Epstein <mjepst_at_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_at_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_at_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_at_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_at_ECTC.ETC
& Subject: WHATEVER
mail will include it in your msg.
**********from rioux_at_ip6480nl.ce.utexas.edu (Tom Rioux)
man mailx
I use someting like this:
echo "From: sysadmin_at_${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!"
Received on Thu Jun 12 1997 - 04:30:05 NZST