2

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?

Community
  • 1
  • 1
mausmust
  • 105
  • 1
  • 1
  • 7
  • 2
    By curiosity, why do you not want to use mutt? It is the ideal tool for that kind of job... – fge Dec 20 '11 at 13:23

2 Answers2

0

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?

Community
  • 1
  • 1
0

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.

mouviciel
  • 66,855
  • 13
  • 106
  • 140