offlineimap nametrans

Date: 2022-04-03

modDate: 2022-04-04

tags: offlineimap notmuch emacs neomutt

I wanted to add a second email provider and have it integrated into my current Maildir folder so I didn’t have to jump through hoops configuring notmuch, emacs, and neomutt to use different Maildir directories.

The offlineimap nametrans doc hints at that but at least for me wasn’t clear enough on how to set that up.

In a new local repository section I added:

nametrans = lambda foldername: re.sub('\.gandi$', '', foldername)

And in a new remote repository section I added:

nametrans = lambda foldername: re.sub('(^INBOX|^Sent)', foldername + '.gandi', foldername)

folderfilter = lambda foldername: re.search('^INBOX$', foldername) \ or re.search('^Sent$', foldername)

The remote nametrans adds a suffix to my INBOX and Sent folders so they won’t collide with my other mail provider. The local one removes the suffix so it can be mapped back to my new provider.

The folderfilter restricts my download email to just those two folders.

Then in my first mail provider’s local repository section I added the below so offlineimap won’t try and sync the second providers folders to it:

folderfilter = lambda foldername: not re.search('\.gandi$', foldername)

You can find the scripts here