在 Redhat 中如何从文件中提取文本并将其作为正文通过电子邮件发送?

How do you pull text out of a file and Email it as the body in Redhat?

我们有另一个软件将数据保存到 rtf 文件中。我们需要提取该数据并将其作为电子邮件正文通过电子邮件发送。在 SCO Unix 中我们可以这样使用:

mailx –s “Subject of email” email@example.com </text.rtf

但现在我们 运行 Redhat 使用的 mailx 包是一个完全不同的包,只会将文件作为附件附加。非常感谢有关此主题的任何帮助。

我们遇到了类似的问题,并通过 shell 脚本伪造 mailx 解决了这个问题。更改 $PATH 以便首先找到您的 "mailx" shell 脚本。 在这个脚本中我们使用 sendEmail(Perl 脚本,看这里http://caspian.dotconf.net/menu/Software/SendEmail/)来发送邮件:

sendEmail $ABSAUTH $(echo \-u "$(echo ""|sed -e 's/^-s//')") -t 

我们最终改用邮件命令。

$ mail –s “Subject of email” email@example.com < /text.rtf

一些文档可以在 https://www.binarytides.com/linux-mail-command-examples/ 或使用 "man mail" 命令找到。