NIU Department of Mathematical Sciences
Exchanging Files by E-mail

STUCK? SEARCH INDEX MAIN

Contents

Encoding binary files
Sending files by e-mail
Receiving encoded files
TeX files
Word Perfect, Word etc.
Large files
Very large files
Printing

Most e-mail systems transmit only the basic ASCII character set, which is the lowest common denominator in the computer world. However, you will often need to send (or receive) a file in a different format, such as a binary executable program or a .dvi file.

Most of what follows applies to Unix systems. Modern Mac and PC mail applications such as Eudora or Pegasus Mail handle this problem by using so-called MIME attachments (explained below).

The Unix utility uuencode and its companion uudecode were designed to solve this problem: they are used to convert a binary file into an ASCII equivalent, and to restore the original file from the ASCII representation. However, this method has disadvantages and should not be used unless it's necessary.

Modern standards call for compliance with MIME (Multipurpose Internet Mail Extensions), which uses primarily something called a base 64 encoding method. Whenever you receive a mail message marked as containing MIME content (e.g. in elm it will be marked with an M next to it), chances are that it was encoded using base64.

Encoding

Given a binary file named - say - `program', type
mpack -o program.enc program
This will create a file `program.enc' containing the ASCII form of the binary file. You can now send it by regular e-mail (but see below for a simpler method).

Note: there is no point at all in uuencoding plain text files such as PostScript or TeX!

Sending encoded files by mail

Let's first repeat that you should encode files to be sent only when it's necessary - doing this with plain text files is wasteful and annoying to the recipient, who might not have a very easy way to decode them.

Some mail programs let you specify what "attachments" should be added to the letter. In pine there is a menu choice for doing this. In elm you can say something like

  [include paper.dvi application/octet-stream base64]
in the body of the letter, and the file `paper.dvi' will be encoded and attached to your message according to MIME conventions.

You could of course use the editor to simply read in the already encoded file into the text of your letter, but you shouldn't do that: none of the special MIME mail headers will be created in this case, and the recipient's mail program will not be able to decode the file automatically.

Probably the fastest (and recommended) way to send a binary file to someone is to use our friend mpack in mail mode. To send a file `paper.dvi' to someone just type

  mpack -s "Here is my paper" paper.dvi someuser@some.place.edu

Receiving encoded files

If you use a "smart" mail program like pine or elm, and if the letter was sent according to MIME standards, then the mail application should handle the decoding end of things. You will probably be asked what to do with the file - e.g. whether to save it to disk for later use.

If nothing like this has happened (e.g. if you use ordinary Unix mail, which knows nothing about MIME), then you should first save the message to a file, and then decode it manually. For example, if the letter was saved in a file called `from-bob', then at the Unix shell prompt simply type

  munpack from-bob
Do not remove mail headers from the file before running it through munpack. The program needs some of them to do the work, and is smart enough to skip all others.

The decoder is also very careful about not overwriting existing files. If the resulting file was supposed to be called `program' but you already have a file by that name, munpack will use the name `program.1' or some such.

TeX

TeX files can exist in essentially three forms. Here is a little chart which will help you decide which format to use for sending by e-mail: If you want to mail a PostScript file to avoid compatibility hassles, read about mailing very large files.

WordPerfect, Word etc.

Suppose you receive a DOS WordPerfect document, or a Macintosh MS Word file as an attachment. After the mailer does its work decoding it (or if you do it manually as described above), you will end up with a file which cannot be used on our workstations, because we don't have Unix versions of the required programs.

You should now learn to use FTP to transfer the file from your Unix account to a PC or a Mac. Remember that you will need to use the binary or MacBinary transfer mode.

Obviously, the process can be reversed. If you want to send someone an Excel document, first upload it to your Unix account, and then use mpack to mail it, as described above.

Large files

Some e-mail systems can handle files up to a few hundred kilobytes or so. Many can deal with much larger files, but you shouldn't count on that. It's a good idea to compress any file larger than 100 KB before mailing it. Text files (such as PostScript) can be shrunk a lot that way; on the other hand, "densely packed" binary files such as GIF graphics do not usually benefit from compression.

Given a file `myfile', type

gzip myfile
You will get a file `myfile.gz', which will be anywhere from 10% to 50% smaller than the original. The file can be restored to its normal form with
  gunzip myfile.gz'
Trouble with this is that the compressed file is binary, even if the original was plain text. This means that you always have to encode it before sending (see above).

Very large files

If the file involved is over a megabyte and cannot be compressed much, the file transfer utility called FTP is a better choice than e-mail. To allow outside people to transfer files to you, or to make your files available to the public, you can use our anonymous FTP directory. Tell the other person to connect to ftp.math.niu.edu with the username `ftp' and password being their e-mail address; they should then change the directory to pub/contrib, and upload the file there. If the other person uses a Web browser, things are even simpler: connect to the URL
  ftp://ftp.math.niu.edu/pub/contrib
and tell the browser to upload the file.

When this is done, you should notify the system manager so he can transfer the file to your home directory.

If you want to transfer a large file to someone, that person should ask the local system administrator to make similar arrangements for a "drop box" directory on the remote system.

If you are not too concerned about others getting the file, an even better choice is to place it on your personal Web page under some non-trivial name which won't be easy to guess by casual "surfers". The other person can then retrieve it using the full URL of the file, e.g.:

  http://www.math.niu.edu/~behr/bizarrename.html
Your homepage must contain a readable file called `index.html', or else anyone accessing that page will see a listing of all the files, which defeats the semi-privacy of this scheme.

Please do not let other people use your password to transfer files directly to or from your account!

Important note about printing

When you receive a PostScript file by mail, do not send it directly to the printer! Since the file begins with e-mail headers, it will not be recognized as a PostScript program, and your printout will consist of hundreds of pages of useless text. Use an editor to delete all lines up to (but not including) the line which starts with something like %!PS-Adobe-2.0 (or just %!). The printer will then treat the file as PostScript.

Large PostScript files (a megabyte or more) can fail to print on a Unix computer unless you use the -s option to lpr, e.g.

lpr -s -Pm1 hugefile.ps


Last modified: 6/6/97 by webmaster@math.niu.edu