I am trying to attach one file and send few echo messages in the Body of an email using mailx and uuencode. I have below command which I have added them together, and uuencode doesn’t work properly but I get echo message properly in my email.
How can I make uuencode works here? Something wrong I am doing here I guess while combing uuencode with mailx?
(uuencode /tmp/chart.html percentage_graph.html) | mailx -s "LIP Data Quality Report for $DATE_YEST_FORMAT1" -r rj@host.com rj@host.com <<EOF
Data Successfully loaded into LIP_DATA_QUALITY table
Total Items Purchased: `echo $QUERY1 | awk '{print $1}'`
Total Items MissingorMismatch: `echo $QUERY1 | awk '{print $2}'`
Error Percentage: $QUERY2
EOF
But for testing purpose if I issue below command to see whether I am getting any html file or not in an attachment, then I get an email with the attachment properly.
(uuencode /tmp/chart.html percentage_graph.html) | mailx -s "LIP Data Quality Report for $DATE_YEST_FORMAT1" -r rj@host.com rj@host.com
Then what’s wrong in my first command when I combine them together?
The
mailxcommand can get its input from the pipe (uuencode) or the heredoc (<< EOF). But not both.This may work for you:
Alternately, consider using something like mutt which will let you attach files separately from the body of the message.