Alpine with Office365 using Modern Authentication (OAuth2)

Summary: Instructions for installing Alpine in a Linux home directory and configuring to use OAuth2 for Office 365 e-mail.

NOTE:  This is not officially supported by Technology Services (Campus IT) or Engineering IT - but these instructions are provided due to request - Use at your own risk.

The list of officially supported e-mail clients is available at:  https://answers.uillinois.edu/97955

Installing Alpine 2.26:

Depending on your Linux Distribution, available alpine packages may be too old to connect to Microsoft 365.  These instructions show how to install Alpine 2.26 in your Linux home directory:
 
NOTE: You may need install some dependencies to build this software such as ncurses-devel or libncurses-dev.
 
mkdir -p ~/alpine-2.26/build
cd ~/alpine-2.26/build
wget https://alpineapp.email/alpine/release/src/alpine-2.26.tar.xz
tar Jxvf alpine-2.26.tar.xz
rm -f ~/alpine-2.26/build/alpine-2.26.tar.xz
cd ~/alpine-2.26/build/alpine-2.26
./configure --prefix=$HOME/alpine-2.26/
make
make install
rm -rf ~/alpine-2.26/build
cd ~/
export PATH=~/alpine-2.26/bin:$PATH
 
Note:  You will need to add 'export PATH=~/alpine-2.26/bin:$PATH' or similar to your .bashrc or .profile to modify your $PATH
 

Configuring Alpine

First - we'll run the program and quit it to generate a default ~/.pinerc file:
  1. Run the command 'alpine'
  2. Press 'E' to exit the default greeting
  3. Press 'Q' to quit (and 'Y' to confirm)
Now use your favorite text editor to modify your ~/.pinerc file and update the following fields:
personal-name=YOURLASTNAME, YOURFIRSTNAME
user-domain=illinois.edu
 
customized-hdrs=From: "YOURLASTNAME, YOURFIRSTNAME" <YOURNETID@illinois.edu>
smtp-server=smtp.office365.com/user=YOURNETID@illinois.edu/submit/auth=xoauth2
inbox-path={outlook.office365.com/ssl/user=YOURNETID@illinois.edu/auth=xoauth2}INBOX
postponed-folder={outlook.office365.com/ssl/user=YOURNETID@illinois.edu/auth=xoauth2}Drafts
trash-folder={outlook.office365.com/ssl/user=YOURNETID@illinois.edu/auth=xoauth2}Deleted Items
folder-collections=mail/[],Office365 {outlook.office365.com/ssl/user=YOURNETID@illinois.edu/auth=xoauth2}[]
Open Alpine again and you should be greeted with the message "Authorizing Alpine Access to Outlook Email Services":

Go to the URL from the message (https://microsoft.com/devicelogin) and enter the provided code - complete the web-based Office 365 based authentication steps.  Once you have completed the authentication steps in your browser, Alpine will prompt (at the bottom) "Preserve Refresh and Access tokens on DISK for next login?"  Select 'Y'.

Alpine will then create a "Master Password File" (at ~/.pine-passfile) - this is how Alpine protects your authentication to Office365 without having to go through the web-based authentication each time.  Create a master password for Alpine as prompted (and a second time to confirm).

Now you should be able to go to your "INBOX" and see your e-mail.
If you go to the Folder List you should see an "Office 365" option to see your account sub-folders (this is from the "folder-collections" setting in ~/.pinerc)
When you start alpine going forward, it will automatically prompt for the Alpine "master password" (the message is "Enter password of key <MasterPassword> to unlock password file:") - this is NOT your NETID password, but the password you created above - it is specific to Alpine only.

Official Documentation:



Keywords:
linux alpine mail email oauth2 pine 
Doc ID:
119374
Owned by:
Eddie W. in Engineering IT
Shared Services
Created:
2022-06-29
Updated:
2023-11-20
Sites:
University of Illinois Engineering IT