Sending File Attachments


Some people get confused about email. "If email is just text, and only text, how do people send me fully formatted documents and all those family pictures?" The capability to attach binary files is one of the extensions to SMTP that makes it more useful.

There are several methods for turning a binary file into text for mailing, which are somewhat tied to the operating system you're running. The historic Unix method is called UUEncode/UUDecode (the UU standing for Unix-to-Unix), whereas Macintosh users made BinHex files. Later on, the Multipurpose Internet Mail Extension (MIME) format came in for all operating systems. Nearly every mail client now produced, for whatever OS, can read file attachments that use these formats, and they all can attach files using at least one of these methods without user intervention. That is, you don't have to decide how to encode your attachments.

One deficiency in this encoding and textifying of binary files is that the encoded files are much bigger than the original binary file. Recently, a new format called yEnc has taken the field, claiming to produce smaller, more compressed attachments. Client support for this format is spotty at the time of this writing, but that may change.

In the event you find yourself needing to decode one of these files manually, this section will help you with some pertinent details about each format.

When do you need to manually decode an attachment? If you get a message that has a large batch of random digits, characters, and apostrophes in 80-characters-per-line format, that's probably an undecoded attachment. If you see a line at the top of the randomness with a filename, you definitely have an undecoded attachment. See the section "Using UUDeview to Decode a File Attachment" to know what to do with it.

Note

Microsoft Exchange Servers use a proprietary format to attach files to Outlook messages. This format, the Transport Neutral Encapsulation Format (TNEF), is read beautifully in Outlook itself, but other clients (regardless of OS) sometimes have a problem, with attachments being labeled with a generic winmail.dat filename.

Progress has been made in viewing these files in Linux mail clients. KDE (and KMail) has a built-in TNEF viewer. Other clients can use the shell utility TNEF to view these files. This utility is available through YaST.


BinHex

Apple Macintosh users have long used the BinHex format to wrap files. This hasn't changed with the advent of the FreeBSD-based OS X. SUSE Linux users can install UUDeview from YaST to decode these files. This shell utility decodes all manner of attached-file formats, including yEnc and MIME.

yEnc

This format, with a name derived from smushing together the words "My Encoder," is freely available. Mostly used in the Usenet binaries newsgroups, it can also be used for attaching files to email. The developer, Jürgen Helbring, insists that if you use it in email, you must include the word "yEnc" in the subject heading. This serves both to warn recipients that there is an attachment with this message and to spread the word about the format.

UUDeview will decode these attachments for you. You'll find a list of yEnc-friendly Linux applications at http://www.yenc.org/linux.htm.

UUEncode/UUDecode

These venerable utilities are included in the sharutils package installed by default in SUSE Linux. If you know you have a UUEncoded file, you can use UUDecode to extract the file. The telltale sign that an attachment has been UUEncoded is that in the top line, along with the filename, is the three-digit permissions indicator.

Suppose the first line in the attachment looks like this:

begin 664 vacation027.jpg 

This tells us that when it's decoded, we'll have a single JPG image, vacation027.jpg, when we're done. You can UUEncode any number of files in a single instance.

When you get an email like this, save it as a file in your home directory. Leave it with no extension (attach1). Then go to your shell and run the UUDecode program:

uudecode attach1 

This will decode the attachment and produce the vacation027.jpg image in your home directory. You should now see this file if you run the ls command, and you should be able to open it. After you've opened the decoded file, delete attach1.

MIME/Base64

MIME is the general Internet standard for formatting email. It includes the Base64 method for encoding file attachments, as well as messages using non-English characters.

Heinz Tschabitscher at About.com briefly describes what happens when you use Base64: "Base64 encoding takes three bytes, each consisting of eight bits, and represents them as four printable characters in the ASCII standard."

Use UUDeview to decode Base64 attachments.

Using UUDeview to Decode a File Attachment

What do you do when you find yourself with an undecoded file attachment? Follow these steps.

1.

As we did with the preceding UUEncoded message, use the Save As command in your mail client, save this message in your home directory, and call it attach1 with no extension.

2.

Go to a shell or console. Type this command:

uudeview -p Documents attach1 

This will decode the attachment (whatever form was used to encode it) and place the decoded file(s) in your Documents directory. Type uudeview (with no switch) to see a list of all the options.

3.

Go to the Documents directory (either by cd-ing in the shell or opening a file manager) and open the newly decoded file(s).

After you've opened the decoded file, there is no need to keep the original attachment.

Note

When you have decoded a file attachment, you have just turned it back to a binary file. To view or execute it, you still have to open the decoded file(s).




SUSE Linux 10 Unleashed
SUSE Linux 10.0 Unleashed
ISBN: 0672327260
EAN: 2147483647
Year: 2003
Pages: 332

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net