If you are using the department Web IMAP, you'll possibly want to leave mails on your mail spool. In this situation, you may want to use IMAP on Mew too. Here, I'll explain how to setup Mew to use IMAP over SSL. For the general information on how to setup Mew, please read another page too.
Stunnel
To use IMAL over SSL, you need to use stunnel (http://www.stunnel.org/). Mew supports both Stunnel-3.x and Stunnel 4.x. Stunnel is already installed on junkfood machine, so you can just add /usr/imports/stunnel/sbin to your $PATH environment variable to use it.
Import certificate
To use SSL properly, you need to install a department certificate. This page explains general information on the department SSL certificate, and what you need to do is to get the cert file and put it at the proper location with the proper name as follows.
- Open this page with your browser. (You may see the warning if you haven't set up your browser.)
- Save the file cacert.cer linked from this page.
- Run the following command:
$ openssl x509 -hash -noout -in cacert.cer
This outputs a string like "a0208049". The cert file should be renamed to this string + ".0" and be stored in ~/.certs.
$ mkdir ~/.certs
$ mv cacert.cer ~/.certs/`openssl x509 -hash -noout -in cacert.cer`.0
You can confirm stunnel is working by the following command (where "nnnnn" is an arbitrary unused port number.)
$ stunnel -c -f -d localhost:nnnnn -a ~/.certs -v 1 -D debug -P none -r ringding.cs.umd.edu:993
then on the second console,
you will see a verification error on the first console if a cert is not installed properly. Otherwise you will see an IMAP prompt on the second console.
$ telnet localhost nnnnn
If necessary, more information on setting up a CA certificate is found here.
(Optional) Installing Stunnel
Just in case you need to install stunnel by yourself, below is a summary of commands for installing Stunnel-3.26. (I have written this because I didn't find stunnel on junkfood machine first:) After it is completed, you need to add stunnel to your PATH environment variable. In the case above, stunnel would have be installed in $HOME/local/sbin. (You can change the directory name as you wish, of course.)
$ cd (somewhere)
$ wget http://www.stunnel.org/download/stunnel/src/stunnel-3.26.tar.gz
$ gzip -d < stunnel-3.26.tar.gz | tar xf -
$ cd stunnel-3.26
$ ./configure --prefix=$HOME/local
$ make (You will be asked to enter your DN during compiling. Just come up with something and enter it.)
$ make install
IMAP folder setup
The current department IMAP server makes an entire home directory visible to a client. Under this setting, Mew tries to scan the whole files in ~/ when creating the folder index by default, which is time-consuming and useless. One way to avoid this is to make Mew use an "MH directory" setting instead. To allow the IMAP server to use this mode, you need to create a file ~/.mh_profile and write just one line in it:Path: Mail(The file .mh_profile is originally a user configuration file for mh. Here I omit all backgrounds for why this is necessary for IMAP.)
Mew configuration - pop3-like usage
To use IMAP, the content of the file ~/.mew.el should be changed. For a certain reason, the setting in this section is not a common configuration for using imap. (I'll describe an alternative setting in the next section. Take a look at it too, and choose the one you prefer.) The configuration in this section makes Mew use imap in a "pop3-like" manner.
(setq mew-imap-prefix-list '("#mh/" "#mhinbox"))
(setq mew-use-cached-passwd t)
;; Uncomment the following line if you don't want to get mail when startup
;(setq mew-auto-get nil)
(setq mew-config-alist
'(
("default"
("name" . "Your Name")
("mail-domain" . "cs.umd.edu")
("proto" . "+")
("mailbox-type" . imap)
("imap-server" . "ringding.cs.umd.edu")
("imap-ssl" . t)
("imap-ssl-port" . "993")
("imap-size" . 0)
("imap-delete" . t))
("local"
("mailbox-type" . mbox)
("mbox-command" . "incm")
("mbox-command-arg" . "-c -d /var/mail/username"))))
(setq mew-nntp-server "news.umd.edu")
Once it's done, restart emacs and Mew. You will have to press "3Z" ("3", then Shift+"z"), then press enter to update folder list cache when you use IMAP for the first time. You'll be asked a password because now Mew is connecting to the IMAP server instead of reading from the local spool.
When you start Mew or enter "i" in the summary mode, you will be asked a password because now Mew is retrieving mails from the imap server instead of local spool. Except that, everything is the same. Outgoing mails are sent to local host. Read the later section about the password management. Note that the mails will be deleted on the server when you retrieve mail. If you want the server to keep the retrieved mails, set mew-imap-delete to t.
("imap-delete" . nil)
Mew configuration - general imap
IMAP provides much more powerful remote mail management than POP3. To utilize it (really use IMAP), a differnt setting is necessary. Please keep several things in mind, though. First, you should be aware about "remote folder" versus "local folder". This will change the way you use Mew a little bit. Second, the current imap system on the junkfood system does not support such an advanced functions. Until the system is updated, you can't do much better than the previous setting. Take a look at it too, and choose what you prefer.The ~/.mew.el should look like:
(setq mew-imap-prefix-list '("#mh/" "#mhinbox"))
(setq mew-use-cached-passwd t)
;; Uncomment the following line if you don't want to get mail when startup
;(setq mew-auto-get nil)
(setq mew-config-alist
'(
("default"
("name" . "Your Name")
("mail-domain" . "cs.umd.edu")
("proto" . "%")
("imap-server" . "ringding.cs.umd.edu")
("imap-ssl" . t)
("imap-ssl-port" . "993")
("imap-size" . 0)
("imap-delete" . nil))
("local"
("proto" . "+")
("mailbox-type" . mbox)
("mbox-command" . "incm")
("mbox-command-arg" . "-c -d /var/mail/username"))))
(setq mew-nntp-server "news.umd.edu")
Once it's done, restart emacs and Mew. You'll be asked to press "3Z" ("3", then Shift+"z"), as you did in the first method.
After Mew is started, you can retrieve mails from the server by entering "s", then enter. You don't use "i" in the IMAP directory. The retrieved mails are stored in the directory such as ~/Mail/.imap/username\@ringding.cs.umd.edu%imap/. As this name implies, the files in this directory is no longer considered as "real entity". They are just caches of actual mails on the IMAP server.
Copy/move mails to local
Sometimes you may want to copy or move your mail on the spool to your local directory. (Here, "local" means the ~/Mail/inbox directory, for example. Unlike directories under ~/Mail/.imap, a mail in this directory is not a cache.)The quickest way to move mails to local is to enable the local access to the spool and use "i" command. This can be done by the following step. (Caution: after this operation, all mails in the spool are moved to local, so the spool will become empty!)
- In the summary mode, enter "C"
- In the mini-buffer, enter "local" and press the enter key.
- Press "i" to retrieve mails from the spool to the local directory
- In the summary mode, enter "C"
- In the mini-buffer, enter "default" and press the enter key. Now "i" key is disabled.
- To go back to the imap folder, press "g" in the summary mode, and enter "%inbox" then enter. To go to the local inbox, press "g" and enter "+inbox" then enter. (This is part of Mew's folder mechanism. You will understand more if you read the manual about how to refiling messages into folders. here I explained the very minimum stuffs. You can copy or move individual mails too, of course.)
SMTP
A general instruction on authenticated SMTP is found here. In short, what you need to do is a TLS tunnel on either port 25 or 587. (Port 587 is prepared for the access from providers blocking outbound port 25.) Below is the setting you need for the port 25, together with the general imap settings. (Of course, smtp over TLS can be used with POP3-like imap too.) Note that I have added the line "imap-user" in case your junkfood account name is different from the one you use on your pc.
(setq mew-imap-prefix-list '("#mh/" "#mhinbox"))
(setq mew-use-cached-passwd t)
;; Uncomment the following line if you don't want to get mail on startup
(setq mew-auto-get nil)
(setq mew-config-alist
'(
("default"
("name" . "Your Name")
("mail-domain" . "cs.umd.edu")
("proto" . "%")
("smtp-auth-list" . ("PLAIN"))
("smtp-server" . "smtp.cs.umd.edu")
("smtp-port" . "25")
("smtp-ssl" . t)
("smtp-ssl-port" . "25")
("smtp-user" . "username")
("imap-server" . "ringding.cs.umd.edu")
("imap-ssl" . t)
("imap-ssl-port" . "993")
("imap-user" . "username")
("imap-size" . 0)
("imap-delete" . nil))
; The settings for local access may not be necessary for your pc, but
; I just leave it here.
("local"
("proto" . "+")
("smtp-auth-list" . ("CRAM-MD5" "PLAIN" "LOGIN"))
("smtp-server" . "localhost")
("smtp-ssl" . nil)
("mailbox-type" . mbox)
("mbox-command" . "incm")
("mbox-command-arg" . "-c -u -d /var/mail/username"))))
(setq mew-nntp-server "news.umd.edu")
About password
Mew remembers on the memory the password you entered for a short period of time - about 20 minutes. After you didn't use the password during this time period, the password is cancelled and you have to reenter the password. This design is a result of tradeoff between usability and security. There are ways to customize this behavior.- If you don't want Mew to remember the password, set mew-use-cached-passwd to nil:
(setq mew-use-cached-passwd nil)
- If you want Mew to remember the password for longer time period, you can add something like the following to .mew.el. (This example makes Mew remember the password practically long enough.)
(setq mew-passwd-timer-unit 999) (setq mew-passwd-lifetime 999)
- If you really want to, you can write the password in your .mew.el. I don't recommend it for security reason. Entering password one time when you start Mew is not really frustrating at all. If you wrote password in your .mew.el, however, make sure that file permission is set correctly so that the password is not easily readable from others. (chmod 600 ~/.mew.el*)
(setq mew-passwd-alist '(("username@ringding.cs.umd.edu:imap" "password" 0)))