【问题标题】:Linux mail command file attachment [duplicate]Linux邮件命令文件附件[重复]
【发布时间】:2012-01-24 08:41:46
【问题描述】:

可能重复:
How do I send a file as an email attachment using Linux command line?

我想在 linux 中使用 mail 命令发送带有文件附件的邮件。我试过这个:

mail foo@gmail.com < test.txt

但是 test.txt 是作为消息发送的,而不是作为附件发送的。我不想使用 mutt 或其他类型的邮件替代品。我也不想使用 uuencode。如何使用 bash 中的纯邮件命令发送文件附件?

【问题讨论】:

  • 出于好奇,你为什么不想使用 mutt?它是此类工作的理想工具...

标签: linux file bash email attachment


【解决方案1】:

看看How do I send a file as an email attachment using Linux command line?。答案相当完整。所以最好放弃只用 bash 命令解决这个问题的所有希望。这当然是可能的,但不值得痛苦。顺便说一句,为什么人们仍然想要它?

【讨论】:

    【解决方案2】:

    如果您只想使用 mail 将文件作为附件发送,您必须编写自己的 bash 脚本以根据 MIME 及其对 multipart messages 的规范来格式化消息。

    我做过一次,但它并不完美,值得一试,仅用于教育目的。此外,如果您计划附加二进制文件,您将需要某种二进制到 ascii 编码器。当时我找到了我在 bash 脚本中编译和使用的 base64 编码器/解码器的 C 源代码。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-08-10
      • 2014-02-25
      • 2015-11-27
      • 2010-10-28
      • 2017-08-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多