How to send some text in email along with the contents of the file, don't want to send file as an attachment? is it possible via mailx command?
mailx -s "Email log file" [email protected] <$log_file;
$log_file contents gets emailed but below doesn't work
echo "Comment: log contains last month report" | mailx -s "Email log file" [email protected] < $log_file
Needed output in email:
Comment: Log contains last month report
<All contents of $LOG_FILE as text>
Here is how you would do it:
echo "Comment: log contains last month report\n $(cat \$log_file)" | mailx -s "Email log file" [email protected]
The only thing "funny" is you'll have to escape that $ in the filename. You can also add more new lines \n if need be.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With