How to attach a file using mail command on Linux?

Example using uuencode:

uuencode surfing.jpeg surfing.jpeg | mail [email protected]

and reference article:

http://www.shelldorado.com/articles/mailattachments.html

Note:

you may apt install sharutils to have uuencode command


$ echo | mutt -a syslogs.tar.gz [email protected]

But it uses mutt, not mail (or mailx).


mailx might help as well. From the mailx man page:

-a file
     Attach the given file to the message.

Pretty easy, right?


mail on every version of modern Linux that I've tried can do it. No need for other software:

matiu@matiu-laptop:~$ mail -a doc.jpg [email protected]
Subject: testing

This is a test
EOT

ctrl+d when you're done typing.