Computing at SLAC
Search SLAC

Pine: A UNIX email client supporting IMAP and SSL

Pine is a full-featured UNIX email and news client that runs in any character-cell terminal.  The UNIX version of Pine does not have a graphical user interface but it is "screen-oriented", i.e., it uses the full terminal screen rather than just the command line.  Most commands consist of a single keystroke or sometimes a CTRL key combination.  The commands available at any time are displayed on the bottom two lines of the screen; if there are more than will fit, one of the commands will cycle through the other available commands.  There is a UNIX man page for the pine(1) command, plus extensive, context-sensitive, built-in help once you have started a Pine session. Pine can handle some types of attachments itself, and can be configured to hand-off others to separate applications (typically a Web browser).

By default, Pine assumes your INBOX is the local UNIX mail spool and that your other mail folders are in your UNIX home directory, normally in a subdirectory named mail;  however, it can also be configured to use IMAP (or POP) to access mail from one or more servers.  As of version 4.21 (as installed at SLAC in June 2000), IMAP connections can be configured to use Secure Sockets Layer (SSL) to prevent passwords from appearing on the network in the clear.  This means that it can now be used to connect to SLAC's Exchange mail service. This version also includes support for the Light Weight Directory Access Protocol (LDAP) and is configured to access SLAC's LDAP server to search for information about SLAC personnel.


Configuring Pine for a new UNIX user

Pine is configured by default to read your incoming UNIX mail spool file as its primary INBOX, and to put your saved mail folders in $HOME/mail.  New accounts at SLAC are created with a  mail subdirectory with appropriate AFS permissions, so if you are a new SLAC user and only need to read your SLAC mail when logged into a SLAC UNIX host, you should be able to start using Pine immediately with no configuration necessary.  If you sometimes need to read your SLAC mail from other systems (e.g., when logged into a CERN computer or from a Web browser) you may wish to obtain an account on SLAC's Exchange mail service and then follow the directions below to configure Pine as an Exchange client.

Converting to Pine from Elm or other mail programs

Converting to Pine from Elm and certain other email programs which save multiple mail messages to single UNIX files (e.g., the VM Emacs subsystem) is fairly straightforward, since Pine uses the same format for its "mail folders".  Converting from programs like MH that save each mail message as a separate file is more difficult and is beyond the scope of this document.

In converting from another UNIX email program, there are three main issues to address: the location of the saved mail folders; INBOX management; and converting mail aliases.  The remainder of this section will assume you are converting from Elm unless otherwise noted.

Location of saved mail folders

You will need to determine the top-level directory where your saved mail folders are currently stored.  In the case of Elm, the default is $HOME/Mail (note the capital 'M' in contrast to Pine's default of $HOME/mail); however, this default may have been overridden, so you might need to verify the actual location using non-mail-related commands like more(1).

Once you have found the correct directory, you can update your Pine configuration to point to it, if necessary (note that some UNIX mail programs use the same default location as Pine).  However, it may be easier and less confusing in the long run to rename the existing folder to Pine's default.  You might also want to leave a symbolic link from the old name, so that if you have problems during the transition you can temporarily switch back to your old mail program.  Here's an annotated example of doing this, starting from a home directory containing both a Mail (Elm) and mail (Pine) subdirectory (both of these directories are automatically created for new user accounts at SLAC):

   ljm@flora01 > cd                <-- Get to your home directory
   ljm@flora01 > ls -A mail        <-- Verify that Pine directory
                                       has not yet been used
   ljm@flora01 > rmdir mail        <-- Remove empty Pine directory
   ljm@flora01 > mv Mail mail      <-- Rename Elm directory to Pine default
   ljm@flora01 > ln -s mail Mail   <-- Create symlink to Pine directory for Elm
   ljm@flora01 > ls -ld mail Mail  <-- Check result:
   lrwxr-xr-x   1 ljm      sf             4 Jun 15 13:51 Mail -> mail
   drwx------   2 ljm      sf          2048 Jun 15 13:49 mail
Note the second step: if your $HOME/mail directory is not empty you will have to decide what to do with its contents before proceeding.

INBOX management

Incoming UNIX mail is normally delivered by SLAC's mail infrastructure to your mail spool file (/var/spool/mail/$USER), and most UNIX mail programs, including Pine and Elm, know how to find and read this file.  However, there are a variety of different methods for managing it, so sometimes when alternating between different email programs your incoming mail may seem to disappear.  If you are careful to run only one email program at a time, you'll probably find that it has not really been deleted but has simply been copied from your mail spool into a private mail folder; a couple of likely places to look are $HOME/mbox and $HOME/Mail/received.  It is probably not a good idea, however, to run two different mail programs (or even two instances of the same program, especially if they are running on different machines) at the same time.

If you do somehow manage to lose or corrupt your mail spool, hope is not lost!  The file server on which the mail spool is stored keeps several recent snapshots of all mail spool files.  To get a time-ordered list of the available copies of your mail spool, issue the command,

   ls -lt /var/spool/mail/.snapshot/*/$USER

Select the most recent one before the problem occurred (the size of the file might help you determine this if you don't recall when you went wrong) and copy it back to someplace in your mail directory as a new mail folder (if you copy it over your current mail spool you may destroy more recently received mail).  You should do this as soon as possible after you discover the problem, of course, since the good version will age out of the snapshots after a couple of days if you continue to receive new mail.  If the worst happens and you discover the problem too late to retrieve a good snapshot, send mail to unix-admin@slac.stanford.edu to request restoration from a backup tape, specifying as nearly as you can when the problem occurred.

The remainder of this section gives an overview of how Pine and Elm manage the INBOX, but may be skipped if you are not interested in the details.

Pine normally attempts to lock your mail spool file and leaves your incoming messages there until you explicitly delete them or save them to a different folder; however, it also can be configured to automatically copy incoming messages elsewhere under certain conditions. Getting different programs to agree on a robust and reliable file locking protocol in a networked environment can be difficult, however, so for extra insurance Pine can also be configured to reduce the window for lock contention by periodically copying new incoming messages from your mail spool file to a private file, mbox, in your home directory; it then treats this file as the INBOX.  This feature is enabled by simply creating an empty $HOME/mbox file.

Elm makes a private copy of your mail spool in a temporary location (/tmp/mbox.$USER) while it's running and updates it periodically during your session.  When you're ready to exit Elm, it asks "Keep unread messages in incoming mailbox?"  If you respond 'y', it resynchronizes the temporary and spool copies and puts the result back into you mail spool.  If you instead respond 'n', it appends everything left in the temporary file to your "received" mail box and clears your mail spool.

Converting Elm Mail Aliases

There is a small utility that can convert your Elm mail aliases to a Pine addressbook.  It can be found at /afs/slac/package/pine/elm-to-pine; you can get help with the syntax via the -h option:

   ljm@flora06 > /afs/slac/package/pine/elm-to-pine -h
    Usage e.g.
    elm-to-pine ~/.elm/aliases.text >~/.addressbook

    Option:
      -s    Create a single address for multiple nicknames by making
            additional nicknames point back to the first one.

Note that you must enter the full path name of the command and that the output goes to STDOUT and must be redirected to a file via the '>' shell metacharacter.

Configuring Pine as a SLAC Exchange client

This section assumes you have previously used Pine (or another UNIX mail program like Elm) and so you already have some mail saved in mail folders in your UNIX home directory.  We will therefore add your Exchange folders as a second folder collection rather than immediately replacing your UNIX folders with Exchange folders.  If you eventually import all your existing mail folders into Exchange (or simply discard them once they've become obsolete), you can delete your UNIX folder collection at that time.  If you've never used UNIX mail before and have no existing folder, you can still follow this procedure and then immediately delete the UNIX folder collection afterwards.

We will also assume that your UNIX INBOX is currently empty and that you have created a .forward file and updated your mailrouter entry to direct all future email to your Exchange account. If you need continuing access to your old UNIX INBOX, you should continue with the section,  Configuring Additional INBOXes or Folder Collections, when you have finished here.

Tips for Exchange users

Here are some additional suggestions for using Pine as an Exchange client.

Configuring additional INBOXes or folder collections

If you have additional email accounts on other servers (for example, a Leland account on campus or a POP account from a commercial Internet Service Provider), you can configure Pine to access them as well. If you have not yet moved all your email from your UNIX INBOX into other folders, you may want to add it as an additional INBOX as well.

Other Configuration Options



Last Updated: March 18, 2005
Owner: Len Moss