Difference between revisions of "CalMail conversion and Unix mail"

From UCB Math Wiki
Jump to: navigation, search
 
(15 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 +
{{Outdated}}
 +
 +
 +
=CalMail Conversion and Unix Mail=
 +
 
This page describes how to use CalMail using tools similar to the Unix
 
This page describes how to use CalMail using tools similar to the Unix
 
mail program (mailx, generally accessed by typing "mail").
 
mail program (mailx, generally accessed by typing "mail").
Line 4: Line 9:
 
After conversion to CalMail on April 6, incoming mail will no longer be
 
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,
 
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'''
+
and must be accessed by a mail reader capable of using the '''IMAP'''
 
protocol.  The Unix mail program does not have this capability, so if
 
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
 
you are using this program then you will need to make some changes in
Line 15: Line 20:
 
[[CalMail conversion]] wiki page.)
 
[[CalMail conversion]] wiki page.)
  
The first method of accessing mail involves a program called '''fetchmail''',
+
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
 
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'''
 
directory.  You then access the mail using the standard Unix '''mail'''
 
program (or any other mail program, for that matter).
 
program (or any other mail program, for that matter).
  
In the other method, you use the "Gnu" version of the Unix '''mail''' program,
+
It is also possible to use both methods in combination with each other.
called '''gnumail'''. It functions very similar to the original mail program,
+
 
but it is capable of using IMAP.  In that case, '''gnumail''' is able to treat
+
If you have set up your CalMail password already, then you can experiment
the CalMail server as if it were your inbox.
+
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 that '''nail''' on the department's FreeBSD server
 +
'''blue2''' is known as '''mailx'''.  It is available as '''nail''' on Solaris and Linux machines.)
 +
 
 +
== Using nail ==
 +
 
 +
The "heirloom mailx" version of the Unix mail program (called '''nail''' on linux and Solaris, but called '''mailx''' on FreeBSD)
 +
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 editheaders PAGER=more
 +
 +
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 you run '''nail'''.
 +
There are two ways to do this.
 +
 
 +
The recommended way is to use the gnome keyring.  This requires some setup;
 +
see the wiki page [[Using Gnome Keyring]] for instructions.
 +
 
 +
Another way to avoid typing your password repeatedly is 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.
  
It is also possible to use both methods in combination with each other.
+
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
 +
Again, this is not recommended, because this is your CalNet passphrase, which can
 +
be used to access your employee benefits among other things.
 +
 
 +
=== Usage ===
 +
 
 +
Once things have been set up, you can read mail by typing the command
 +
'''nail'''
 +
instead of '''mail'''.  (On blue2, the command is '''/usr/local/bin/mailx'''.)
 +
Then proceed as you would using the Unix '''mail''' command.
 +
 
 +
==== 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
 +
[https://calmail.berkeley.edu CalMail's web interface].  
  
It should be noted, however, that the CalMail IMAP server for the math domain
+
More information on '''nail''' is available on its extensive manual page, which
will not be operational until after the transition, so you will not be able
+
can be obtained by typing:
to try out the methods described here until after April 1. (If you have
+
  man nail
access to another email account with an IMAP or POP server, however, you
+
Note that the man page refers to the command as '''mailx''', but it is
will be able to experiment with that server.  Although the math
+
installed as '''nail''' here ('''mailx''' is "taken" by the system command).
department has its own IMAP server, it is not recommended that you use
 
it to try things out.  It has a bad habit of corrupting users'
 
mailboxes, especially those with large amounts of incoming mail.)
 
(Note also that '''gnumail''' is currently installed only on Solaris machines
 
(such as '''blue1''' and '''blue3''').)
 
  
 
== Using fetchmail ==
 
== Using fetchmail ==
Line 52: Line 140:
 
CalMail password will likely be stored in a file in your home directory,
 
CalMail password will likely be stored in a file in your home directory,
 
and is vulnerable to being compromised.
 
and is vulnerable to being compromised.
 +
 +
(Note: as discussed on the [[CalMail conversion]] page, as of Sept 2009,
 +
your '''CalNet pass-phrase''' replaces your CalMail password.  To protect
 +
your pass-phrase, it is therefore especially important to set your '''.fetchmailrc''' file to
 +
be readable only by you, as explained below.)
  
 
After the transition, the directory '''/var/mail''', which is used for
 
After the transition, the directory '''/var/mail''', which is used for
Line 81: Line 174:
 
exactly as given above (except for optionally changing your inbox).
 
exactly as given above (except for optionally changing your inbox).
  
== Using gnumail ==
+
=== Usage ===
  
The Gnu version of the Unix mail program is capable of directly accessing
+
Once '''fetchmail''' has been set up as described above, actual usage is straightforward.
your inbox on the CalMail server.  You can do this on an ''ad hoc'' basis
 
by naming the CalMail server directly on the command line:
 
gnumail -f imaps://'''''username'''''%40math.berkeley.edu@calmail.berkeley.edu
 
As in the description of '''fetchmail''', you should replace '''''username'''''
 
with your math department login name.  After typing this command, '''gnumail'''
 
will prompt you for your CalMail password.
 
  
Typing the above command is a bit inconvenient.  It is recommended that if
+
To read new mail, first you retrieve it, by running:
you plan to use '''gnumail''' often, then you set up '''gnumail''' to access
+
  fetchmail
your CalMail account by default.  To do this, create a file named '''.mail'''
+
Then you read it, by typing (as usual):
in your home directory.  Its contents should be as follows:
+
  mail
  mailbox {
 
  mailbox-pattern "imaps://'''''username'''''%40math.berkeley.edu@calmail.berkeley.edu";
 
}
 
You can also avoid having to type in your password every time, by placing it
 
in the '''.mail''' file:
 
  mailbox {
 
  mailbox-pattern "imaps://'''''username'''''%40math.berkeley.edu:'''''password'''''@calmail.berkeley.edu";
 
}
 
  
[http://www.gnu.org/software/mailutils/manual/html_node/mail.html#mail Additional documentation]
+
There are some options to '''fetchmail''' that sometimes come in handy:
on '''gnumail''' is available on the web.
+
; '''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.

Latest revision as of 11:58, 4 January 2019

Ambox content.png Some or all of the information on this page is outdated, irrelevant or confusing. Please help clean it up if you are able.


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 must 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 that nail on the department's FreeBSD server blue2 is known as mailx. It is available as nail on Solaris and Linux machines.)

Using nail

The "heirloom mailx" version of the Unix mail program (called nail on linux and Solaris, but called mailx on FreeBSD) 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 editheaders PAGER=more

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 you run nail. There are two ways to do this.

The recommended way is to use the gnome keyring. This requires some setup; see the wiki page Using Gnome Keyring for instructions.

Another way to avoid typing your password repeatedly is 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

Again, this is not recommended, because this is your CalNet passphrase, which can be used to access your employee benefits among other things.

Usage

Once things have been set up, you can read mail by typing the command nail instead of mail. (On blue2, the command is /usr/local/bin/mailx.) Then proceed as you would using the Unix mail command.

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

Note that the man page refers to the command as mailx, but it is installed as nail here (mailx is "taken" by the system command).

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.

(Note: as discussed on the CalMail conversion page, as of Sept 2009, your CalNet pass-phrase replaces your CalMail password. To protect your pass-phrase, it is therefore especially important to set your .fetchmailrc file to be readable only by you, as explained below.)

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

Once fetchmail has been set up as described above, actual usage 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.