簡體   English   中英

如何使用mailx將文件作為文本發送並向電子郵件正文添加額外的文本?

[英]How to use mailx to send file as text and add extra text to email body?

如何在電子郵件中發送一些文本以及文件內容,不想將文件作為附件發送? 可以通過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>

以下是您將如何做到這一點:

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

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM