complete-computing-environment/mbsync.org

137 lines
5.4 KiB
Org Mode

:PROPERTIES:
:ID: cce/mbsync
:ROAM_REFS: http://isync.sourceforge.net/mbsync.html
:ROAM_ALIASES: mbsync
:END:
#+TITLE: mbsync for local mail storage
#+filetags: :Emacs:Tool:Communication:
#+PROPERTY: header-args :mkdirp yes :results none
#+PROPERTY: header-args:emacs-lisp :tangle mbsync.el
#+PROPERTY: header-args:yaml :tangle roles/endpoint/tasks/mbsync.yml
#+ARCOLOGY_KEY: cce/mbsync
#+ARCOLOGY_ALLOW_CRAWL: t
#+AUTO_TANGLE: t
#+ARROYO_EMACS_MODULE: mbsync
#+ARROYO_MODULE_WANTS: cce/async_forever.org
#+ARROYO_MODULE_WANTED: cce/run_hooks_after_init.org
#+begin_src emacs-lisp
(provide 'cce/mbsync)
(add-hook #'after-cce-hook (lambda () (cce/async-forever "date && mbsync -a" "*mbsync*" 600)))
#+end_src
I have mixed feelings about using [[http://isync.sourceforge.net/mbsync.html][mbsync]] in my [[id:26c9e4fd-4501-4b8b-95ce-a2a5230d7c1e][Email and News and Information Pipelines]], I've had enough issues with mail integrity that it's useful to have a [[id:cce/python][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 [[id:cce/ssh_configuration][SSH Configuration]][fn:2:(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.
#+ARROYO_HOME_MODULE: hm/mbsync-endpoint.nix
#+ARROYO_NIXOS_ROLE: endpoint
#+begin_src nix :tangle ~/arroyo-nix/hm/mbsync-endpoint.nix
{ config, pkgs, ... }:
{
programs.mbsync.enable = true;
accounts.email.maildirBasePath = "/home/rrix/Maildir";
accounts.email.accounts.endpoint = {
address = "ryan@whatthefuck.computer";
realName = "Ryan Rix (rrix)";
aliases = [ "ry@n.rix.si" "rrix@fastmail.com" ];
userName = "rrix@fastmail.com";
primary = false; # outbox goes through fastmail smtp
passwordCommand = "pass show fastmail_email_app";
imap.host = "fontkeming.fail";
imap.tls.enable = false;
mbsync = {
enable = true;
subFolders = "Verbatim";
groups = {
endpoint = {
channels = {
high-priority = {
extraConfig.Create = "near";
patterns = [
"fastmail/INBOX"
"fastmail/github"
"fastmail/Sent\\ Mail"
"fastmail/fedora/bugs"
];
};
low-priority = {
extraConfig = {
MaxMessages = 1000;
MaxSize = "10m";
Create = "near";
ExpireUnread = "no";
};
patterns = [
"fastmail/newsletters"
"fastmail/social"
"fastmail/emacsconf"
"fastmail/phoenix-lug"
"fastmail/RecruitingSpam"
"fastmail/Junk Mail"
"fastmail/1ml"
"fastmail/1ml/bcz"
"fastmail/1ml/friendsofsecurityplanner"
];
};
feeds = {
patterns = [
"feeds/Art"
"feeds/Blogs"
"feeds/Brain"
"feeds/Motorsports"
"feeds/News"
"feeds/Self"
"feeds/Software"
"feeds/Tea"
"feeds/Tech"
"feeds/Videos"
"feeds/Longreads"
];
extraConfig = {
MaxSize = "10m";
Create = "near";
ExpireUnread = "no";
};
};
work = {
patterns = [
"crdigital/INBOX"
"crdigital/[Gmail]/Sent Mail"
];
extraConfig = {
MaxMessages = 1000;
MaxSize = "10m";
Create = "near";
ExpireUnread = "no";
};
};
};
};
};
extraConfig = {
account = {
Timeout = 120;
Tunnel = "ssh -q fontkeming /usr/libexec/dovecot/imap";
};
};
};
};
}
#+end_src
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 [[id:fa7e9d10-a98d-4036-a668-889bd1d3ea29][offlineimap]].