Using Secure IMAP with PINE and MUTT

Before getting started: Configuring PINE and MUTT

Both PINE and MUTT store their configuration/setup in resource files, or dot-rc files, (.pinerc for PINE, .muttrc for MUTT, in your home directory,) in a format that will be familiar to most UNIX users.

PINE has the added advantage that most (but not all) options are configurable through the PINE program itself, and will automatically update the .pinerc file for you. PINE also creates a skeleton dot-rc file for you, the first time you run PINE. So all of the options are listed, even if they're not set to any specific value.

If you're comfortable editing your dot-rc files yourself, then making these changes with either mail program should be a piece of cake. If not, then you might find using the configuration menus within PINE easier.

Quick setup or TL;DR

This document attempts to explain as much about the why and how as possible, but if you just want to get up and running, and don't have the time to read the whole thing, then here are the changes you want to add to your .pinerc (for users of pine and alpine) or .muttrc (for users of mutt) file.

However, I strongly urge you to come back and read the whole document if you have problems, as it will give you some idea of where things are going wrong, and what to do about it.

For pine, add the following lines to your .pinerc file:

user-domain=uwaterloo.ca
smtp-server=connect.uwaterloo.ca/submit/tls/user=
yourusername
inbox-path={connect.uwaterloo.ca/tls/user=
yourusername}INBOX
folder-collections="UW Connect" {connect.uwaterloo.ca/tls/user=
yourusername}[]

For mutt, add the following lines to your .muttrc file:

set hostname=uwaterloo.ca
set imap_user=
yourusername
set folder=imaps://connect.uwaterloo.ca/
set spoolfile=imaps://connect.uwaterloo.ca/INBOX
set record="+Sent Items"
set postponed=+Drafts
set smtp_url="smtp://
yourusername@connect.uwaterloo.ca:587/"
set ssl_starttls=yes
set smtp_authenticators=login

Getting started: Connecting to the mail server the easy way

If you just want to connect to your inbox, that's fairly easy.

pine -f '{connect.uwaterloo.ca/tls/user=yourusername}INBOX'
  or
mutt -f imaps://yourusername@connect.uwaterloo.ca/INBOX

This is more than enough, if all you want to do is read mail, view an attachment, or otherwise not make huge changes to your mailbox.

But typing -f blahblahblah all the time gets cumbersome, and so we have a configuration option that says "Make my inbox default to here:". In your .pinerc file:

inbox-path='{connect.uwaterloo.ca/tsl/user=yourusername}INBOX'
  or in your .muttrc file:
set imap_user=yourusername
set spoolfile=imaps://connect.uwaterloo.ca/INBOX

Certificates

If you see the message "unable to get local issuer certificate". This means that PINE cannot tell if the server you're connecting to is what it claims to be.

There are a two options here. One is to ignore the fact that you can't verify the certificate, and the other is to get your administrator to install the necessary certificate for you. For more information on this, please see the Pine+OpenSSL HOWTO.

With MUTT, this is a bit easier for the end user. You can create a local file that contains your stored certificates so that you'll know if the certificate has changed.

In your .muttrc file, add an option:

set certificate_file=.muttssl

Mail folders and staying organised

By default, PINE sets up INBOX, sent-mail and saved-messages folders for you, on your local system. If you want instead, to use the same folders on the server, you need to configure PINE to look there, instead of on your local machine.

You can set the following variables in your .pinerc file. Note that you can set some of them by going throught he configuration menus within PINE, but not all of them.


folder-collections={connect.uwaterloo.ca/user=
yourusername/ssl}[]

If you set the folder-collections variable, then PINE will look there for your Drafts, saved and sent folders. (PINE will replace the [] for the appropriate folder for you.)

The exact location of the folders depends on the server you connect to. The math mail servers at Waterloo use regular directories in your home directory on the unix filesystem. So if you use pine on the math servers, this will be "[]". Some servers, such as mailservices will use "INBOX.[]". If you're unsure, check with your system administrator.

MUTT has similar folders, sent-mail and postponed, among others.

set folder=imaps://connect.uwaterloo.ca/
set record="+Sent Items"
set postponed=+Drafts

Again, the exact setting for the folder variable depends on your server settings. Note that MUTT uses "Mail" instead of PINE's "mail".

Sending mail

While not strictly IMAP, if you're going to be reading your e-mail remotely, you'll also want to connect to the mail server to send your mail as well.

In PINE, you can do this by setting the smtp-server variable:

user-domain=uwaterloo.ca
smtp-server=connect.uwaterloo.ca/tls/user=
yourusername

MUTT recently added the ability to send mail through a remote SMTP server:

set hostname=uwaterloo.ca
set smtp_url="smtp://
yourusername@connect.uwaterloo.ca:587/"
set ssl_starttls=yes
set smtp_authenticators=login

If something goes wrong

If you have problems connecting to the mail server, it's important to figure out which layer is causing the problem.

  1. Can the user log on to the web-based mail client at https://connect.uwaterloo.ca/? If they can't, maybe they don't have an account set up, or their password is wrong.
  2. If you've just added the options to the .pinerc file listed in the Quick setup section, try removing all of those, except for the inbox-path line, to see if they can at least connect, and see their inbox. If that works, then add the other lines in one at a time until pine starts complaining.