5

如何在电子邮件中发送一些文本以及文件的内容,不想将文件作为附件发送?可以通过mailx命令吗?

mailx -s "Email log file" abc@mail.com <$log_file;

$log_file 内容通过电子邮件发送但以下不起作用

echo "Comment: log contains last month report" | mailx -s "Email log file" abc@mail.com < $log_file

电子邮件中需要的输出:

Comment: Log contains last month report

 <All contents of $LOG_FILE as text>
4

1 回答 1

2

以下是您的操作方法:

echo "Comment: log contains last month report\n $(cat \$log_file)" | mailx -s "Email log file" abc@mail.com

唯一“有趣”的是你必须在文件名中转义 $ 。如果需要,您还可以添加更多新行 \n。

于 2016-04-18T22:58:34.727 回答