How to attach a file using mail command on Linux?

Issue

I’m on a server running a Linux shell.
I need to mail a simple file to a recipient.
How to do this, prefereably using only the mail command?

UPDATE: got a good solution, using mutt instead:

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

Solution

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

Answered By – Jon

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published