Question

I am trying to use mailx function to send an e-mail to my personal email address.But I never received an email.Can someone help me pls. Here is my command below.

PRI_EMAIL_SUBJECT="Some Blah Blah"
PRI_EMAIL_ADDRESS="bobby.teja@gmail.com"
PRI_EMAIL_BODY="$PRI_SETS_RAN_SUCSFL_CNT no. of sets ran successfully."

echo "Sending e-mail"
mailx -s $PRI_EMAIL_SUBJECT $PRI_EMAIL_ADDRESS < $PRI_EMAIL_BODY
echo
Was it helpful?

Solution 2

This perfectly works.

 echo "something" | mailx -v -s "subject" recipient@somewhere.com

OTHER TIPS

You cannot redirect a string. mailx <$FOO expands the variable FOO and attempts to find a file named like that. But since you (presumably) do not have a file named 3 no. of sets ran successfully. you get a redirection error, and the command fails.

To actually send the contents of the variable as email, try

echo "$PRI_EMAIL_BODY" | mailx

(or maybe use a here document).

Use the -d option of mailx for debug output. This may indicate an issue with the mail transport.

mailx -d -s $PRI_EMAIL_SUBJECT $PRI_EMAIL_ADDRESS < $PRI_EMAIL_BODY
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top