notmuch-mailmover is a tool to move notmuch tagged mails into Maildir folders (e.g., created by offlineimap/mbsync).
For example, you can move all mails tagged as trash
to the Trash
folder.
Some use-cases are:
- delete mail from IMAP server (e.g. move trash mail to a non-synced folder and let offlineimap/mbsync do the rest)
- sync your notmuch tags across devices by using notmuch-mailmover in combination with offlineimap/mbsync (this is similarly to muchsync but easier to setup since you don't need a muchsync server)
- purge old mails from the IMAP server (by moving them out of synced folders)
Only Linux is tested, but Windows and Mac should work as well.
notmuch-mailmover-git is available on the AUR. Use your favorite AUR helper to install it, e.g.
$ yay -S notmuch-mailmover-git
$ nix-env -iA notmuch-mailmover
Otherwise, you have to build from source. You need the following build dependencies:
- Rust
- libnotmuch-dev
Then run
cargo install --git 'https://github.com/michaeladler/notmuch-mailmover/'
It's recommended to run notmuch-mailmover
as part of your notmuch pre-new hook.
You can also invoke notmuch-mailmover
directly, but don't forget to run notmuch new
afterward (this isn't necessary if you add it as a pre-hook).
Running notmuch-mailmover
for the first time will create $XDG_CONFIG_HOME/notmuch-mailmover/config.yaml
.
Then edit the file as you like, see below for an example.
The provided config.yaml does the following:
- move mails tagged as
trash
to folderTrash
- move mails tagged as
sent
to folderSent
- move mails tagged as
archive
to folderArchive
Note: Queries must not overlap (hence the and not tag:trash
clause in the second query).
This is to avoid moving files more than once and checked by notmuch-mailmover before any files are moved.
So, don't worry about it, notmuch-mailmover will complain if your rules are ambiguous.
This work is inspired by afew's Mailmover plugin but doesn't require you to setup rules for each folder individually. Instead, notmuch-mailmover applies your rules once to all folders (so it may be easier to configure if you have many folders).