RE: Help Me with shell script please

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

 



>
> Actually in sendmail command we can use  -F somename@xxxxxxxxxxxxxx so the
> mail will be like it is from somename@xxxxxxxxxxxxxx   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@xxxxxxxx"

# 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



-- 
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