如何将文件输出放入电子邮件正文而不是附件?

How do I put the output of a file in the email body as opposed to an attachment?

我正在使用亚马逊 Linux。我发现以下用于将文件内容作为附件发送的方法

cat /tmp/output.txt | mailx -s "Subject" "myaddress@gmail.com"

但我想做的是将文件的内容作为电子邮件的正文发送,而不是附件。我该怎么做?

您的示例不只是将 /tmp/output.txt 作为消息正文发送。也许此文件的内容被格式化为附件?

试试:

echo "Test message" | mailx -s "Subject" "myaddress@gmail.com"

你使用 "lower level" sendmail 程序。

#!/bin/sh
# cat - ... <<END - cat reads "here document" via its stdin
# empty line after email headers IS REQUIRED

cat - /tmp/output.txt <<END | /usr/sbin/sendmail -- myaddress@gmail.com
Subject: Subject
To: myaddress@gmail.com

END