Not Just Paranoid

Another site by Pete Maynard

CLI Email of the Future: Office 365 and QUB

This is a quick record of the steps taken to setup a local email copy, index, and reading. A list of software used is below, some are optional.

* Optional.


All the software should be available via apt.

sudo apt install getmail notmuch alot w3m pass daemontools


Get the latest sources of getmail from the offical site. Extract, build, and install:

tar xvf getmail-<version>.tar.gz
cd getmail-<version>
python2 build
sudo python2 install

You can use the distrubtion repository for the rest.

sudo dnf install notmuch alot pass w3m


Talks to Office365 via IMAP over TLS. Gets all the emails and stores them locally. Make sure to create the direcotries needed:

mkdir -p ~/mail/staff/{cur,new,tmp}


type = SimpleIMAPSSLRetriever
server =
port = 993
username = <STAFF ID>
password_command = ("/usr/bin/pass", "qub/staff")
mailboxes = ALL

type = Maildir
path = ~/mail/staff/

read_all = False
verbose = 1
message_log = ~/.getmail/staff.log


Indexes the local Maildir, and allows you to apply tags and search mail.



name=<My Name>
primary_email=<My Email>




Once you’ve created the config, run notmuch new to create the database.


A terminal-based mail user agent (MUA) based on notmuch mail indexer.



You’ll need to setup sending accounts.


        realname = <My Name>
        address = <My Email>
        alias_regexp = <My Email>\
        gpg_key = <GPG Key>
        # TODO: Setup msmtp
        # sendmail_command = msmtp --account= -t

        # TODO: Figure out the right location.
        # sent_box = maildir:///~/mail/staff/Sent
        # draft_box = maildir://~/mail/staff/Drafts


Mailcap is a file the defines what should happen when a specific file type is opened in alot (or other MUAs). In this case we want to render text/HTML types using w3m. A CLI browser and web rendering engine.


text/html;  w3m -dump -o document_charset=%{charset} '%s'; nametemplate=%s.html; copiousoutput

Work flow


getmail && notmuch new && alot


Touch $HOME/.getmail/do-not-run if you want to prevent getmail from running. This might be to save power or you just don’t want emails coming in. We have also used setlock to prevent multiple instances running at once. This is to prevent strange things from happening.

crontab -e

*/10 * * * * [ -f $HOME/.getmail/do-not-run ] || /usr/bin/setlock -n $HOME/.getmail/run.lock /usr/bin/getmail && notmuch new


Syncing the unread/read flags via IMAP. Might need to change over to OfflineIMAP or something?

Sending email

15 Jan 2020 | Tags ( guide )

Website Last Updated on 15 Sep 2023 (CC BY-SA 4.0)

This site uses JQuery and nanogallery2 hosted by
for the Flickr photo feed and GoatCounter for user insights.