【问题标题】:How do I put the output of a file in the email body as opposed to an attachment?如何将文件的输出而不是附件放在电子邮件正文中?
【发布时间】:2016-04-23 18:41:31
【问题描述】:

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

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

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

【问题讨论】:

    标签: linux email amazon mailx


    【解决方案1】:

    你使用“低级”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
    

    【讨论】:

      【解决方案2】:

      您的示例不会仅发送 /tmp/output.txt 作为消息正文。也许这个文件的内容被格式化为附件?

      尝试:

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

      【讨论】:

        猜你喜欢
        • 2018-11-09
        • 1970-01-01
        • 2017-11-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多