I have a requirement to generate report and send them to a distribution list.
The problem I am facing is when sending out the email using mailx. The email address (DL) we have is starting with # and because of this it's not recognizing the email and throwing the below error.
Error:
Send options without primary recipient specified
When I try to put the email under "" then no email has been send out.
I did a echo and could see $RECIPIENT has the full email address as the value.
RECIPIENT=$RECIPIENT"#[email protected]";
echo "$BODY" | mailx -r "$SENDER" -s "$SUBJECT" -a "$ODFILENAME" -a "$LOFILENAME" "$RECIPIENT"
OS is Linux.
How can I solve it?
$RECIPIENTwould start with a#if it is unset or empty when entering this code fragment.#. If that is indeed the correct address, then why do you append it to theRECIPIENTvariable? Does that variable contain anything since previously? It should not contain backslashes or newlines.$RECIPIENT\"#[email protected]\") or the use of nested quotes ($RECIPIENT'"#[email protected]"').