From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <96078613510404.tru64-unix-managers.marc@archive.invalid> From: sher () altek ! com ! my (Sher) Date: Thu, 12 Jun 1997 01:59:30 +0000 To: tru64-unix-managers Subject: SUMMARY: email to list of users X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=96078613510404 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 Lucio Chiappetti Michael C Taylor Cliff Friedel Steve Swinnea "Stephen B. Henry" Richard Eisenman Brian Sherwood Yizhong Zhou "Christopher L. Davis" Mike Epstein Len Senetza Gernot Salzer Russell Johnson 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 #!/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 issue a command (csh) like : foreach i ( `cat addr.list` ) /usr/bin/mailx -s "yoursubject" $i #!/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 = ) { @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[$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 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 foreach i (`cat users`) Mail $i < message.txt sleep 1 end *********from Mike Epstein 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 < --- 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 #!/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 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}