RE: Help Me with shell script please

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>
> Hello All,
>
> I want to send the same mail massage to 100 people, but not in a way doing
> CC or BCC, but just a mail to a unique person...
> I have this 100 people email addresses in one file. The question is this:
> Is there a way to write some script which will do this job ?
>

Here is a basic basic way to do it with on checks.  By the way, can you log
in and run the script from the user whose email address you want the mail to
come from?  THat makes it easier since you an use the "mail" command.  If
not, it is a bit more convoluted (at least for me) since then I use the
"sendmail" command.

Assume your mail message is in message.txt and your emails are in email.txt
(one address per line, no blank line at the end please)
(by the way , i was laughing when you mistyped message as "massage".
Imagine if you did "mail" as "male" and I'd be like that's something
interesting to send out to 100 people

Okay..disclaimer: untested, non-guaranteed . Change pathnames as you see
fit.  No sanity checks.

--8<-- snip --8<---
#!/bin/bash
# 	script for simple bulkmailing

# get the addresses
alist=`/bin/cat ./emails.txt`

# enter loop for each address
for a in $alist
do
	  #verbose output danka
        echo "mailing to $a"

	  #mail away
        cat message.txt | mail -s "insert subject of message here" $a

	  #traffic control
	  sleep 3
done

---8<--- snip ---8<---


that should be it.  If you need to change the "From" email address, let me
know.  It will get a bit more tricky.  For 100 people, this should be
sufficient.  For more than 100, there are a lot more things you'd want to do
with the script that will keep you and your server from getting bogged down.

Also, I recommend that when you run the script you redirect the output to a
text file
lke output.txt and then in a separate window keep track of what's going on
with

tail -f output.txt

That way if the program crashes or mail server crashes you still have
output.txt so you can see what addresses have been sent to and which
haven't.

Good luck
Ben Yau


-- 
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

[Index of Archives]     [CentOS]     [Kernel Development]     [PAM]     [Fedora Users]     [Red Hat Development]     [Big List of Linux Books]     [Linux Admin]     [Gimp]     [Asterisk PBX]     [Yosemite News]     [Red Hat Crash Utility]


  Powered by Linux