emacs-lisp source: :tangle mbsync.el(provide 'cce/mbsync) (defun cce-run-mbsync-forever () (interactive) (cce/async-forever "date && mbsync -a" "*mbsync*" 600)) (add-hook #'after-cce-hook #'cce-run-mbsync-forever)
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 Configuration fn2(admittedly, my SSH configuration should be refreshed), by establishing an SSH tunnel which executes the built-in imap library executable, which provides a locally-authenticated dovecot session over standard input/output.
nix source: :tangle ~/arroyo-nix/hm/mbsync-endpoint.nix{ config, pkgs, ... }: { imports = [ ./mbsync-configuration.nix ./imapnotify-configuration.nix ]; programs.mbsync.enable = true; accounts.email.maildirBasePath = "/home/rrix/Maildir"; accounts.email.accounts.fastmail = { address = "ryan@whatthefuck.computer"; # aliases = [ "ry@n.rix.si" "rrix@fastmail.com" ]; userName = "rrix@fastmail.com"; passwordCommand = "${pkgs.rbw}/bin/rbw get fastmail_email_app"; maildir.path = "fastmail"; imap = { host = "mail.messagingengine.com"; }; }; }
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 .
nix source: :tangle ~/arroyo-nix/hm/imapnotify-configuration.nix{ config, pkgs, ... }: { services.imapnotify.enable = true; accounts.email.accounts.fastmail.imapnotify = { enable = true; boxes = ["INBOX"]; onNotify = pkgs.writeScript "imapnotify-on-notify.sh" '' set -euxo pipefail ${pkgs.rbw}/bin/rbw get fastmail_email_app ${pkgs.imapfilter}/bin/imapfilter -c ${<arroyo/files/imapfilter.lua>} ${pkgs.isync}/bin/mbsync -a # ${pkgs.libnotify}/bin/notify-send 'New mail received' ''; }; }
nix source: :tangle ~/arroyo-nix/hm/mbsync-configuration.nix{ config, pkgs, ... }: { accounts.email.accounts.fastmail.mbsync = { enable = true; subFolders = "Verbatim"; extraConfig = { account = { Timeout = 120; }; }; groups = { all = { channels = { top = { extraConfig.Create = "near"; patterns = [ "INBOX" "1ml" "1ml/bcz" "1ml/friendsofsecurityplanner" "Junk Mail" "RecruitingSpam" "Sent Mail" "emacsconf" "fedora/bugs" "github" "newsletters" "phoenix-lug" "social" ]; }; rest = { extraConfig.Create = "near"; patterns = [ "*" ]; }; }; }; }; }; }