Linux mail command file attachment [duplicate]

杀马特。学长 韩版系。学妹 提交于 2020-01-04 05:47:14

问题


Possible Duplicate:
How do I send a file as an email attachment using Linux command line?

I want to send a mail with file attachment in linux with mail command. I have tried this:

mail foo@gmail.com < test.txt

but test.txt is send as message, not as a attachment. I don't want to use mutt or other types of mail alternatives. Also i DON'T want to use uuencode. How can i send a file attachment with pure mail command from bash?


回答1:


Have a look at How do I send a file as an email attachment using Linux command line?. The answers are pretty complete. So better abandon all hope for solving this with bash commands only. It surely is possible, but it's not worth the pain. BTW why should one want it anyway?




回答2:


If you want to use only mail for sending files as attachments, you have to write your own bash scripts for formatting the message according to MIME and its specification for multipart messages.

I've done it once but it was not perfect and worth the try only for educational purpose. Moreover, if you plan to attach binary files, you will need some sort of binary to ascii encoder. At that time I found the C source code of a base64 encoder/decoder that I compiled and used in my bash scripts.



来源:https://stackoverflow.com/questions/8574529/linux-mail-command-file-attachment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!