The Complete Computing Environment

mbsync for local mail storage

(provide 'cce/mbsync)
(add-hook #'after-cce-hook (lambda () (cce/async-forever "date && mbsync -a" "*mbsync*" 600)))

I have mixed feelings about using mbsync in my Email and News and Information Pipelines, I've had enough issues with mail integrity that it's useful to have a Python thing that I can muck around inside of with print statements to figure out what what the fuck my Maildir did to itself. I have negative feelings towards the way the project is operated, and the fact that the best documentation of the project is bunch of semi-hostile threads on a Sourceforge forum, and I'm not excited for Master/Slave terminology in a sync program…

But it's fast and works and so I'll try to use it again. I have a tiered architecture for my mail; because of the Universal Aggregator, on my laptops I want to always pull my mail from my central server, and so I have two configurations.

Here's the one for getting things from my server to my laptop. Most folks who set up a personal mail cache will configure Dovecot on the server to listen on a port, and set up authentication and firewalling and bla bla bla. Even if you have a VPN and manage to make sure your IMAP server is only on that VPN, you have to set up a password database or some other sort of authentication strategy, fucken sucks. Instead, I build my security on top of my SSH Configuration1, by establishing an SSH tunnel which executes the built-in imap library executable, which provides a locally-authenticated dovecot session over standard input/output.

{ config, pkgs, ... }:

  programs.mbsync.enable = true; = "/home/rrix/Maildir"; = {
    address = "";
    # aliases = [ "" "" ];
    userName = "";
    passwordCommand = "${pkgs.rbw}/bin/rbw get fastmail_email_app";
    maildir.path = "fastmail";

    imap = {
      host = "";

    mbsync = {
      enable = true;
      subFolders = "Verbatim";

      extraConfig = {
        account = {
          Timeout = 120;

      groups = {
        all = {
          channels = {
            top = {
              extraConfig.Create = "near";
              patterns = [
                "Junk Mail"
                "Sent Mail"
            rest = {
              extraConfig.Create = "near";
              patterns = [

The last time I used mbsync, I experienced issues with mail IDs in my newsrc.eld file, which Gnus uses to store which lists I am subscribed too, and also functions as a cache for message and folder states. The latter caching was what caused these issues, I believe, but it was really difficult to debug it. If this happens again, I may switch to offlineimap.

  1. (admittedly, my SSH configuration should be refreshed)↩︎