CalMail conversion and Unix mail

From UCB Math Wiki
Revision as of 15:11, 27 March 2009 by Vojta (talk | contribs) (Added title)
Jump to: navigation, search

CalMail Conversion and Unix Mail

This page describes how to use CalMail using tools similar to the Unix mail program (mailx, generally accessed by typing "mail").

After conversion to CalMail on April 6, incoming mail will no longer be stored on our system. Instead, it will be stored on the CalMail server, and will need to be accessed by a mail reader capable of using the IMAP protocol. The Unix mail program does not have this capability, so if you are using this program then you will need to make some changes in how you access your email.

This page describes two ways in which you will be able to handle your email using the familiar mail program or workalikes. (Of course, our recommendation is to switch to a different mail client, or to use CalMail's web interface. In that case you should see the main CalMail conversion wiki page.)

The recommended way of accessing mail consists of using a newer version of the Unix mail program, called heirloom mailx. This name is rather awkward, so we'll call it by its previous name, nail. It functions very similarly to the original mail program, but it is capable of using IMAP (and has many other enhancements). Because of this, nail is able to treat the CalMail server as if it were your inbox.

An alternative way of accessing mail involves a program called fetchmail, which copies your mail from the CalMail server into a file in your home directory. You then access the mail using the standard Unix mail program (or any other mail program, for that matter).

It is also possible to use both methods in combination with each other.

If you have set up your CalMail password already, then you can experiment with these methods (although you won't be able to process incoming mail until after the transition). You can also try them with other IMAP or POP accounts that you may have. (Although the Math Department has its own IMAP server, it is not recommended that you use this particular server to try things out. It has a bad habit of corrupting users' mailboxes, especially those with large amounts of incoming mail.) (Note also that nail is currently installed only on Solaris machines, such as the login servers blue1 and blue3.)

Using nail

The "heirloom mailx" version of the Unix mail program (called nail) is capable of directly accessing your inbox on the CalMail server.

Initial setup

To set up nail for accessing your CalMail account, you need to add the following line to the file .mailrc in your home directory:

set NAIL_EXTRA_RC=~/.nailrc

(If you currently do not have such a file, create it with just that one line.)

Then, you should create a file .nailrc in your home directory, which should look something like this:

unset hold
unset emptybox
set crt bsdflags

account calmail {
   set folder=imaps://username@math.berkeley.edu@calmail.berkeley.edu
}

account calmail

In the above, you should replace username with your Unix login name. When you start up nail, it will then ask for your CalMail password.

You can avoid having to type your password every time by adding a line

set password-username@math.berkeley.edu@calmail.berkeley.edu="password"

to your .nailrc file. Again, username should be replaced by your Unix login name and password by your CalMail password. This line can be anywhere in the file outside of the set of braces.

If you place your CalMail password in the .nailrc file, then you should ensure that this file is not publicly readable, by issuing the command

chmod 600 ~/.nailrc

Usage

Once things have been set up, you can read mail by typing the command

nail

instead of mail. Then proceed as before.

Using IMAP Folders

The IMAP protocol allows you to have several folders on the server, and move messages between them. You can access these folders from nail by prepending a "+" sign to their names. For example,

save +folder

will save the current message to the folder named folder. Of course,

save file

will save the message to the file file on our Unix system, as before.

To move to a given folder on the IMAP server, type

folder +folder

This may be abbreviated to "fold +folder". To get a list of folders in the server, type

folders

To start up nail within a given folder, type

nail -f +folder

(Of course, "nail -f file" will refer a file on our system, as before.)

Folders can be created and deleted using CalMail's web interface.

More information on nail is available on its extensive manual page, which can be obtained by typing:

man nail

Using fetchmail

Using the fetchmail program, you can copy your incoming mail from the CalMail server to a file within your home directory, and then read mail using your favorite mail client.

Initial setup

In the following descriptions, you should change username and password to your Math login name and your CalMail password, respectively. It is highly recommended that you use a different password for CalMail access than for logging in to the math system, since the CalMail password will likely be stored in a file in your home directory, and is vulnerable to being compromised.

After the transition, the directory /var/mail, which is used for storing users' inboxes, will no longer be available for that purpose. Therefore, you should choose a file within your home directory to use to hold incoming mail. The following examples use a file name "inbox", but you are free to change it to something else if you like.

In order for Unix mail to be able to find your new incoming mail box, you need to set an environment variable. To do this, add a line of the following form to the file .cshrc in your home directory:

setenv MAIL ~/inbox

Next, you need to provide fetchmail with the information it needs to be able to access your CalMail account. This is done by creating a file named .fetchmailrc in your home directory. This file should contain the following:

poll calmail.berkeley.edu username username@math.berkeley.edu pass password
  mda "procmail -f %F ORGMAIL=inbox DEFAULT=inbox"

Since this file contains your CalMail password, it should not be publicly readable. To make sure of this, use the following command:

chmod 600 ~/.fetchmailrc

In your .fetchmailrc file, the mda line is very important. Without it, your fetched mail will end up being sent back to CalMail, and will likely end up being lost, since CalMail will recognize it as already having been through their mail server once. Be sure it is exactly as given above (except for optionally changing your inbox).

Usage

Using the setup established above is straightforward.

To read new mail, first you retrieve it, by running:

fetchmail

Then you read it, by typing (as usual):

mail

There are some options to fetchmail that sometimes come in handy:

fetchmail -a
Without options, fetchmail retrieves only unread messages. With this option, fetchmail will retrieve all messages. Normally this will not make a difference, but sometimes you may have read messages by some other method (such as the web interface) and may want to download the read messages.
fetchmail -k
This will leave the messages on the server instead of deleting them. It is useful for testing. Note that fetchmail will not delete messages from the server if for some reason it is unable to store the message successfully.
fetchmail -ak
The above two options can be combined.