I am trying to use mailx to send an email via shell script.
Message=<HTML><BODY><p>FINISHED</p></BODY></HTML>
[email protected];[email protected]
Recipients=$(echo "${Recipients}" | sed "s/;/ /g")
echo "Recipients: ${Recipients}"
mailx -s "Ingestion Report ${EXT1}. $( echo "\nContent-Type: text/html")" "${Recipients}" < $MESSAGE
my problem is I'm trying to change the list delimited by a semi-colon to a space-delimited list because I"m told that is what's needed by mailx.
However, the response is:
sh: [email protected]: not found
what am I doing wrong? thanks.
A semicolon is a command separator, so you have to change how you are defining Recipients
from:
[email protected];[email protected]
To:
Recipients="[email protected];[email protected]"
Quoting the value prevents the ;
from being interpreted as a command separator.
Alternatively, you can just define Recipients
correctly in the first place:
Recipients="[email protected] [email protected]"
Or if you don't control that for whatever reason, you can drop the sed
call and just do:
mailx ... ${Recipients/;/ }