Send a file as a mail attachment using mail command.

The simplest way to send a file as a mail attachment is shown by the following examples:

# uuencode snoopy1.jpeg snoopy1.jpeg | mail

If user uses a current mail reader like Mozilla, Netscape Messenger or Microsoft Exchange, she/he will see a mail containing just one file attachment: the file “snoopy1.jpeg”.

This way we can include text, too:

# (cat mailtext; uuencode snoopy1.jpeg snoopy1.jpeg) | mail

The file called “snoopy1.jpeg” again appears twice on the uuencode command line: the first time to specify the input file name, the second time for the remote extraction file name.


echo -e "text in line1 ntext in line2"| mail -s "Subject of an e-mail" -r "User1<>" -a "/tmp/"

Leave a Reply

Your email address will not be published. Required fields are marked *