【问题标题】:How to send email with attachment in Unix如何在 Unix 中发送带附件的电子邮件
【发布时间】:2020-03-12 08:54:31
【问题描述】:

我正在尝试通过运行 shell 脚本发送带有 2 个附件的电子邮件。下面是代码:

echo "hi attached is the xml file requested.regards Team."| mailx -a this/is/the/path/tools/v2/xml/bad_out/0106_out.xml,this/is/the/path/tools/v2/xml/bad_out/0107_out.xml muc@tm.com,ti@b.com

以下是我得到的错误:

mail: invalid option -- a
Usage: mail [-iInv] [-s subject] [-c cc-addr] [-b bcc-addr] to-addr ...
            [-- sendmail-options ...]
       mail [-iInNv] -f [name]
       mail [-iInNv] [-u user]

我也用一个附件尝试了相同的代码,但它仍然给我同样的错误。我还希望正文不是在一行中,而是采用这种格式:

Hi
Attached is the xml file as requested.
Regards
Team.

【问题讨论】:

标签: linux shell unix email-attachments


【解决方案1】:

你可以试试下面的命令:

echo -e "Hi\nAttached is the xml file as requested.\nRegards,\nTeam" | mailx -s "Attachments" -a file1 -a file2 example@domain.com 

【讨论】:

  • 我尝试了上面的命令,它仍然给我同样的错误。
  • 这很奇怪。我在 Linux 7 上进行了尝试,它对我来说非常好。
猜你喜欢
  • 2012-06-07
  • 2015-08-28
  • 2019-01-18
  • 2013-02-07
  • 2011-01-28
  • 2014-04-24
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多