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

RE: Help Me with shell script please



>
> Actually in sendmail command we can use  -F somename somedomain com so the
> mail will be like it is from somename somedomain com   username
> (in the FROM
> Field of the receivers mail client).
>
> But how we can use the mail and sendmail together in one script, so that
> sendmail command will resolve the FROM Problem, and the mail
> command will do
> the rest part of this TASK ?


In that case, just use sendmail instead of mail.  It's not as clean as
solution as the Mail::Internet example Jason just posted.  So if you'r
comfortable with Perl, use that.  If you are more comfortable with sendmail
and shell/file interaction, you'd do something like this in your script
(note the use of additional file messageout.txt).

Have the message itself (no headers) in message.txt
list of email addresses in email.txt

And a script similar to this (untested, didn't do a syntax check)

#!/bin/bash


# get list
alias=`/bin/cat ./emails.txt`
fromaddress="from from com"

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

	# form message
	echo "Subject: this is your subject" > ./messageout.txt
	echo "To: $a" >> ./messageout.txt"
	echo "" >> ./messageout.txt"
	cat ./message.txt >> ./messageout.txt

	# send message
	cat ./messageout.txt | /usr/lib/sendmail -f $fromaddress $a

	# traffic control
	sleep 3
done





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