Mail is designed to handle only text messages, which means that if you try to send a binary file thorough the mail it will not be received as a binary file. To send a binary file thorough the mail it must be turned into text (since that is what mail understands). After the file is compressed you can use UUencode to turn the file to text for transport.

Command Format:

uuencode filename

The following example encodes the file spread.sheet.Z and uses a pipe ( | ) to mail it to a user.

$ uuencode spread.sheet.Z | mailx -s "The Spreadsheet" user@host

Now to extract the file on the receiving end switch to your home directory and run the uudecode command on the mbox file:

$ uudecode mbox

You can now uncompress it with the uncompress command:

$ uncompress spread.sheet.Z