Welcome to the ``tip of the week'', a pithy kickshaw provided on a sometimes weekly basis. Files in the mail: MIME, uuencode, and other encodings ------------------------------------------------------ Situation Report: you have received a mail message, perhaps with a few odd-looking statements about encoded messages, followed by some lines of blocky-looking gibberish. Your Mission: read the mail. The mission plan involves two main steps and several contingencies. Good luck, and remember that today is a good day to flame your correspondent if he/she/it came up with a truly exotic file format to waste your time. Nomenclature: `encode' is used below to denote schemes for repackaging binary files into text files for convenient transmission through text-only media such as electronic mail. `encoding' and `encryption' are entirely different issues: we are not discussing tools for privacy and secrecy in this Tip. `File compression' is also a separate matter: this phrase refers to techniques for reducing the size of a file. You may receive material which has been both compressed and encoded. First steps ----------- (0) The initial steps are managerial and diagnostic. Save your mail message as a file, say ``myfile''. You may want to move this file into a sparsely populated subdirectory. (1) Look over your mail message, either within your mail reader or by using `more' or an editor to examine the saved file. If there are some lines about MIME-encoded files, then follow step (2) below. If instead you see a line which looks roughly like ``begin 644 filename'', then you should skip to step (3). MIME-encoded files ------------------ (2) Run the utility `munpack' (think MIME-unpack) on your file: munpack myfile You may get more files, or other sorts of files, than you bargained for. It pays to do this chore inside a subdirectory which contains few or no other files so that you can recognize the new stuff. (Extra material may include files with the suffix `.desc' and files with names like ``part1.'') Now skip to step (4). uuencoded files --------------- (3) If instead of the MIME header gibberish you see a line which looks roughly like ``begin 644 filename'', then you should save your message as a file with a name *other* than the one on that begin line, perhaps ``myfile'' and apply the Unix utility `uudecode': uudecode myfile uuencoding, like MIME-encoding, allows one to transmit binary files (which require 8 bits per character) in email (which only handles 7-bit characters reliably). Any document type might be transmitted in this form. Go on to step (4). After the deluge ---------------- (4) Munpack and uudecode automatically attach the names of the file or files extracted from your encoded mail message. You may encounter filename suffixes like these after the unpacking, which may lead to subsequent file processing before you can view the incoming material. File-compression and packing flags *.gz GNU-zipped file - use gunzip *.Z compressed file - use gunzip or uncompress *.tar tar archive - use `tar -xvf' to extract the archive *.tgz tarred and gzipped archive - gunzip first, then use `tar -xvf' *.uu, *.uue uuencoded (usually binary) file - use `uudecode' A few document types *.ps PostScript - if you want to print it, be sure that the very first characters in the file are %!PS, then use `lpr filename' (Try the ghostview previewer on your document before printing. Some word processors made by Very Well Known Companies may produce unprintable PostScript unless they get a helping hand.) *.avi, *.wav Multimedia records which are basically unsupported here. *.gif, *.jpg Image file formats - use xv, xli, or one of the Web viewers Afterword --------- More help is available in the online manual pages for munpack, gunzip, uncompress, tar, and uudecode. Use a command line such as man munpack or use the X Windows manual page tool available under the main window menu (pull up the Documentation/Manpages menu item) to get more details. (5) Cleanup: After you successfully decode it, you probably want to delete the original mail message, both from your mail reader and the saved file. MIME-encoded and uuencoded binary files tend to be substantially larger than their originals. (6) We conclude with some possible sources of trouble. (a) You may receive a file in the Macintosh BinHex format. We do not currently seem to have tools for this. Our Macintosh users may be of some help, but you should tell your correspondent that you prefer uuencode instead. (b) Someone may try to send a binary file (such as a TeX dvi file) through electronic mail without encoding it somehow. This almost always fails. Tell your correspondent to use uuencode first or to send the file as a MIME attachment (we would use `mpack' for this). (c) Someone may send you a family album, the collected works of a favorite cartoonist, or a digitized sound recording as a MIME attachment. Large files can fill up the spooling area on our mail server, which inconveniences everyone in the department and is therefore a leading cause of Sympathy Deficit Disorder. In addition, some mail agents choke on very large files. Tell your correspondent to use another transfer method and to ask your permission before transmitting large documents. (d) Your correspondent may believe that the whole world uses Word Perfect, Microsoft Word, Framemaker, or another proprietary document formatting tool. This is not true. Tell your correspondent to learn TeX or another portable tool. In the worst case, your correspondent should use that expensive copy of WordMangler XCV.3 to save a document in a format labelled as `ASCII', `formatted ASCII', `plain text', `DOS file', or something similar. Then the two of you can pass the document back and forth via email without the pain of the encoding schemes described above. It is often worth while to work on the substance of a document before formatting is applied, so you and your correspondent may be able to do without the clever features of WordMangler for the first few passes at a text. ---------------------- Past Tips of the Week are found in /depot/documentation/tips. They may also be consulted through the Documentation/Online Help menu item of the window system's main menu or through Info mode in the Emacs editor. cws@math.ufl.edu Subject: Files in the mail: MIME and uuencode