0

I'm trying to use a variable in the text of an email using sendmail, but it just sends the variable name not the value. I tried this on the command line:

(base) [me@home-page-two backup]$ $TODAY=$(date +%d-%m-%Y)
(base) [me@home-page-two backup]$ $MY_MESSAGE="Today's date is $TODAY"    
(base) [me@home-page-two backup]$ cat <<'EOF' - /home/me/backup/email.txt |/usr/sbin/sendmail -t
To: me@example_email.com
Subject: This is another test email
"${MY_MESSAGE}"
EOF
(base) [mee@home-page-two backup]$

This is clearly not the way to do it, I've tried various combinations of quotes and braces, how can I send the variable contents in the email. Currently the email comes through and in the body is just shows:

"${MY_MESSAGE}"

I'm trying to acheive:

Today's date is 28-08-2020
iFunction
  • 1,208
  • 5
  • 21
  • 35

0 Answers0