2015-01-20 46 views
0

如何发送电子邮件中的一些文本以及文件的内容,不想将文件作为附件发送?有没有可能通过mailx命令?如何使用mailx将文件发送为文本并向电子邮件正文添加额外的文本?

mailx -s "Email log file" [email protected] <$log_file; 

$ LOG_FILE内容获取电子邮件,但低于不起作用

echo "Comment: log contains last month report" | mailx -s "Email log file" [email protected] < $log_file 

电子邮件所需的输出:

Comment: Log contains last month report 

<All contents of $LOG_FILE as text> 
+1

可能是http://stackoverflow.com/questions/2282506/how-can-i-send-an-email-through-unix-mailx-command的副本。至少,该链接回答了问题 – mpez0 2015-01-20 22:15:23

+0

谢谢你会尝试一下。 – homer 2015-01-20 22:18:33

回答

0

这里是你会怎么做:

echo "Comment: log contains last month report\n $(cat \$log_file)" | mailx -s "Email log file" [email protected] 

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

相关问题