Storing offlineimap passwords using pass

2017/07/21

Short note on using pass to store passwords for offlineimap. First add the password for email account:


pass insert <accountname>

To allow offlineimap to retrieve the password, create a Python script (accessible via PATH):


!# /usr/bin/python2 
from subprocess import check_output

def get_pass(account): 
    return check_output("pass " + <accountname>, shell=True).splitlines()[0]

Make this accessible to offlineimap via the configuration file by adding the location of the above script:


[general]
pythonfile = <path to get_pass script>

Then in the email repository config add:


[Repository account]
remotepasseval = get_pass("<accountname>")

This now allows offlineimap to use pass to store passwords for your email servers.