I am having issues sending emails to multiple recipients. The script is running well, creating files with the list of recipients from a table but not sending emails. I want to attach the file also. Here is a part of the script; please let me know the issue. Thank you.
if [ -s dataStnd_viol_addr.log ]; then
if [ ${update_instance} == "BPROD" ]
then
##########echo | mailx -s "***** Data Standard Violation - Address *****" -S
"[email protected]" -a "dataStnd_viol_addr.log" ${BPROD_LIST};
while read dest;
do
echo | mailx -s "***** Data Standard Violation - Address *****" -S
"[email protected]" $dest < $REPORT/dataStnd_viol_addr.log
done < $REPORT/Email_PRODlist.lst
elif [ ${update_instance} == "B8QA" ]
then
while read dest1;
do
echo | mailx -s "***** Data Standard Violation - Address *****" -S
"[email protected]" $dest1 < $REPORT/dataStnd_viol_addr.log
done < $REPORT/Email_QAlist.lst
else
while read dest2;
do
echo | mailx -s "***** Data Standard Violation - Address *****" -S
"[email protected]" $dest2 < $REPORT/dataStnd_viol_addr.log
done < $REPORT/Email_DEVlist.lst
fi
fi
cd ${working_dir}
working_dir=""; export working_dir
working_sql_dir=""; export working_sql_dir
update_instance=""; export update_instance
days_back=""; export days_back
You're providing input to mailx both with a pipe and with redirection. I don't know which takes precedence. I'd recommend removing all the
echo|bitsAlso, there seem to be 2 competing redirections, and mailx might be slurping up the input to the while loop.
Try this:
readis using file descriptor 3 andmailxis using file descriptor 1, no potential for conflict.Note that this won't attach the file: the file contents will be the message body. Check if your version of mailx has a
-aoption.