E-mail using IMAP with text-based clients with Nexus 365

Some people find web-based or other graphical mail clients cumbersome or unwieldy, and there are circumstances under which using a graphical interface is inconvenient or simply not possible. Here are our recommendations for text-based mail clients on desktop systems in Physics.

Replacement strategy

The configuration instructions use metavariable names, which you should replace with values pertaining to you:

  • replace abcd1234 by your University-wide SSO username (usually of the form phys1234);
  • replace my_physics_login by whatever you (used to) use to log into Physics's mailers;
  • replace My Real Name by however you wish people to address you-as-you formally.

Please note that where @OX.AC.UK is specified, using capital letters is important.

BEFORE YOU START:

Use the Web interface to log into Nexus365:

This will verity that your mailbox is present, and that your SSO and password really do match. (If you're doing this before the migration, don't worry if your inbox looks a bit thin or old, or if you find folders missing. We're discovering here whether you can talk to Nexus365 at all.)

Fundamentals

  • Ext username: abcd1234@OX.AC.UK # (amend as above)
  • Incoming:
    • Site: outlook.office365.com
    • Prococol: IMAPS (port 993)
  • Outgoing:
    • Site (on-site): smtp.ox.ac.uk
    • Site (off-site): smtp.office365.com
    • Protocol: SMTPS (port 465)

Pine, and Alpine

Configuration

This is done by editing the file .pinerc in your home directory, or equivalently (for some settings, but not all) by entering Setup inside pine. Please take a copy of this file before you update it as insurance, and as documentation of what used to work (including settings not discussed here).

IMAP settings: access your inbox

This will permit you to read incoming e-mails, and to move them between folders. You will be prompted for your SSO password when you invoke alpine. (It's possible to also put your password in your startup file, but putting sensitive information like that in a text file is Considered Harmful.)

inbox-path={outlook.office365.com:993/ssl/novalidate-cert/user=abcd1234@OX.AC.UK}Inbox

Apologies if the above appears in a box with a slider. The syntax is important, and there's no way to fold this line properly. Please drag the slider to the right, or click Expand to see the text all at once.

Mail folders

To see mail folders other than Inbox from Nexus365 in alpine add the following line:

folder-collections=Nexus365folders {outlook.office365.com:993/ssl/novalidate-cert/user=abcd1234@OX.AC.UK}[]

If this does not work, please see the folder-collection line in:

Stanford's Alpine configuration suggestions

.... and be creative; then let us know what you did, and whether or not it worked, so we can amend this section.

Copies to self

To file copies to yourself in the Sent Items folder, add:

default-fcc={outlook.office365.com:993/ssl/novalidate-cert/user=abcd1234@OX.AC.UK}Sent Items

SMTP (outgoing mail), on-site:

For desktop systems or servers on-site, please use:

smtp-server=smtp.ox.ac.uk:587/tls/novalidate-cert/user=abcd1234@OX.AC.UK

This is known to demand you enter your password for each e-mail sent. Ways of working round this are under investigation.

SMTP (outgoing mail), off-site:

For laptops, and other systems off-site, please use:

smtp-server=smtp.office365.com:587/tls/novalidate-cert/user=abcd1234@OX.AC.UK

.... and let us know whether you have problems other than with being nagged for passwords.

Further reading:

Please see also (and compare and contrast):

Stanford's Alpine configuration suggestions
Florida State Uni's suggestions

.... and be prepared to make local substitutions.

Mutt, and neomutt

This has been shamelessly stolen from mutt-office365 on Github, with hints from Stanford's mutt configuration suggestions, and some local modifications.

Build and configuration

The copy of mutt to be used should have TLS (nee SSL) and PGP support. For example, the version we distribute to Apple desktop systems with MacPorts is built using:

port install neomutt +gdbm +imap +gnutls +gpgme +mutt

.... where +mutt adds a symbolic link, so it can be invoked as "mutt" under the Principle of Least Surprise.

When mutt starts up, it looks for the file .muttrc or .mutt/muttrc in your home directory. The directives below go there. (Please note that the order of definitions in one's .muttrc is significant.)

IMAP settings: access your inbox

This will permit you to read incoming e-mails, and to move them between folders. You will be prompted for your SSO password when you invoke mutt. (It's possible to also put your password in your mutt startup file, but putting sensitive information like that in a text file is Considered Harmful.)

set imap_user="abcd1234@OX.AC.UK" # capital letters matter here
set folder="imaps://outlook.office365.com:993/"

set imap_check_subscribed="yes"
set imap_list_subscribed="no" # See below
set timeout=15
set mail_check=90
set imap_keepalive=180
set imap_idle
unset mark_old
set ssl_use_sslv3=yes

Please note: mutt-office365 includes set imap_list_subscribed="yes", which results in one's Directory browser display being empty, and disables the perniciously-useful tab completion mechanism for folder names. Disabling imap_list_subscribed is an experimental variation (implicit in Standford's suggestions), which we have found re-enables Directory listing and tab completion. We reserve the right to revert this suggestion in the light of experience.

Mail folders

This lets you access the mail folders you specify in the Mailboxes browser. The macro definition is a single line which has had to be backslash-folded twice to fit in this margin; the list of mailboxes shown is merely an extremely truncated example (my full list stretches halfway to the horizon).

set spoolfile=+INBOX
mailboxes +INBOX +code-coffee +oxcert +backups # .... snipissimo
# NB: These two lines must come after the IMAP settings block.

# Add keystroke aliases to enter and leave Browser mode.
#
macro index,pager y \
"<change-folder>?<toggle-mailboxes><toggle-mailboxes>" \
"show incoming mailboxes list"
#
bind browser y exit

# Ensure any FCC reply is saved in the current folder.
folder-hook . 'set record=^'

Please note: the symbol + in the first two lines means "with respect to my mail directory"; and the IMAP settings block changes that from the default ~/Mail/ to your office365 mailbox. Upshot: said two lines need to come after the IMAP settings block.

Copies to self

Please see the last line in the previous subsection.

SMTP (outgoing mail), on-site:

The settings for Postfix (see the end of this article) will send any outgoing messages to smtp.ox.ac.uk, which will then forward them appropriately. Those here tell mutt to tell the various spam and forgery filters along the delivery path who you are, otherwise mailing lists hosted in (eg) OUITS would be at liberty to drop your submissions on the floor, sight unseen.

set hostname = physics.ox.ac.uk
set realname = "My Real Name"
set from = my_physics_login@physics.ox.ac.uk

SMTP (outgoing mail), off-site:

BOOKMARK: Please let us know if you need this, so we can research and flesh out this section.

Postfix (on-site systems only)

For on-site systems, we recommend you use your system's Postfix in "satellite" mode to forward all mail to a "smarthost", as this is more reliable than configuring your mail client to do so. Apple Mac or Linux desktop systems in Physics should have been set up to use smtp.ox; if you find otherwise, please complain to IT Support at the usual e-mail address.

For completeness, the following should go, or be found, at the end of /etc/postfix/main.cf for systems "in the NAT" (ie most desktop clients), traditionally topped and tailed by comment lines which include "Central Physics Patch".

mydomain = nat.physics.ox.ac.uk
myorigin = physics.ox.ac.uk
relayhost = smtp.ox.ac.uk

Categories: Email | Nexus | Nexus365