| 1 | ;;; -*-emacs-lisp-*- |
| 2 | ;;; |
| 3 | ;;; Local GNUS configuration -- distorted.org.uk version |
| 4 | ;;; |
| 5 | ;;; (c) 2014 Mark Wooding |
| 6 | ;;; |
| 7 | |
| 8 | (setq auth-sources '("~/.authinfo.gpg")) |
| 9 | |
| 10 | ;;;-------------------------------------------------------------------------- |
| 11 | ;;; How to send mail. |
| 12 | |
| 13 | (setq smtpmail-smtp-service 587 |
| 14 | smtpmail-auth-credentials "~/.authinfo.gpg") |
| 15 | |
| 16 | (setq mdw-send-mail-alist |
| 17 | `((distorted-smtp |
| 18 | (send-mail-function . smtpmail-send-it) |
| 19 | (smtpmail-smtp-server . "mail.distorted.org.uk") |
| 20 | (smtpmail-starttls-credentials |
| 21 | ("mail.distorted.org.uk" 587 nil nil))) |
| 22 | (chiark-smtp |
| 23 | (send-mail-function . smtpmail-send-it) |
| 24 | (smtpmail-smtp-server . "smtp.dovecot.chiark.greenend.org.uk") |
| 25 | (starttls-extra-arguments "--insecure") |
| 26 | (smtpmail-starttls-credentials |
| 27 | ("smtp.dovecot.chiark.greenend.org.uk" 587 nil nil))) |
| 28 | (gmail-smtp |
| 29 | (send-mail-function . smtpmail-send-it) |
| 30 | (smtpmail-smtp-server . "smtp.gmail.com") |
| 31 | (smtpmail-starttls-credentials |
| 32 | ("smtp.gmail.com" 587 nil nil)))) |
| 33 | mdw-guess-send-mail-alist |
| 34 | `((,(concat "@\\(" "\\(chiark\\|slimy\\|coriolis\\)" |
| 35 | "\\.greenend\\.org\\.uk" |
| 36 | "\\|" "evade\\.org\\.uk" |
| 37 | "\\|" "fyvzl\\.net" |
| 38 | "\\)$") . chiark-smtp) |
| 39 | ("@g\\(oogle\\)?mail\\.com$" . gmail-smtp)) |
| 40 | mdw-default-send-mail-method nil) |
| 41 | |
| 42 | ;;;-------------------------------------------------------------------------- |
| 43 | ;;; News via chiark. |
| 44 | |
| 45 | ;; Currently we assume an SSH tunnel. This will be fixed later. |
| 46 | (setq gnus-select-method |
| 47 | '(nntp "chiark-ssh-kludge" |
| 48 | (nntp-open-connection-function nntp-open-authinfo-kludge) |
| 49 | (nntp-address "tunnel.chiark.greenend.org.uk") |
| 50 | (nntp-authinfo-generic "md5cookie1way mdw"))) |
| 51 | |
| 52 | ;;;-------------------------------------------------------------------------- |
| 53 | ;;; Mail group configuration. |
| 54 | |
| 55 | ;; General splitting configuration. |
| 56 | (setq nnimap-split-rule 'nnimap-split-fancy |
| 57 | nnmail-split-methods 'nnmail-split-fancy |
| 58 | nnimap-split-predicate "UNDELETED" |
| 59 | nnimap-split-crosspost t |
| 60 | nnmail-split-crosspost t |
| 61 | nnmail-split-fancy-match-partial-words nil) |
| 62 | |
| 63 | ;; Automatic expiry for particular groups. |
| 64 | (setq gnus-auto-expirable-newsgroups |
| 65 | (concat "^" |
| 66 | "\\(nnimap\\+[^:]+\\|nnvirtual\\):" |
| 67 | "\\(" "\\(admin\\|crap\\|lists\\|nag\\)\\." |
| 68 | "\\|" "spam\\.oubliette" |
| 69 | "\\)")) |
| 70 | |
| 71 | ;; My various email addresses. |
| 72 | (setq message-alternative-emails bbdb-user-mail-names |
| 73 | message-dont-reply-to-names message-alternative-emails) |
| 74 | |
| 75 | ;; Augment Gnus's built-in header-list abbreviations. |
| 76 | (require 'nnmail) |
| 77 | (setq nnmail-split-abbrev-alist |
| 78 | (mdw-uniquify-alist |
| 79 | `((to . ,(concat "to\\|cc\\|apparently-to\\|envelope-to\\|" |
| 80 | "resent-to\\|resent-cc")) |
| 81 | (any . ,(concat "from\\|sender\\|resent-from\\|" |
| 82 | "to\\|cc\\|apparently-to\\|envelope-to\\|" |
| 83 | "resent-to\\|resent-cc")) |
| 84 | ,@nnmail-split-abbrev-alist))) |
| 85 | |
| 86 | ;; Find out about my `odin.gg' mappings. |
| 87 | (defvar mdw-odin-parse-regexp |
| 88 | (concat "^" |
| 89 | "\\S-+" "\\s-+" ; time limit |
| 90 | "\\(" "\\S-+" "\\)" "\\s-+" ; local part |
| 91 | "\\S-+" "\\s-+" ; recipient email address |
| 92 | "=" "\\(" "\\S-+" "\\)" ; mailbox tag |
| 93 | "\\(" "$" "\\|" "\\s-" "\\)")) |
| 94 | |
| 95 | (defvar mdw-odin-splits nil) |
| 96 | (defvar mdw-odin-sender-alist nil) |
| 97 | |
| 98 | (defun mdw-update-odin-info () |
| 99 | (let ((splits nil) (senders nil)) |
| 100 | (with-temp-buffer |
| 101 | (call-process "ssh" nil t nil |
| 102 | "stratocaster" "userv" "odin" "mail" "list") |
| 103 | (goto-char (point-min)) |
| 104 | (while (< (point) (point-max)) |
| 105 | (when (looking-at mdw-odin-parse-regexp) |
| 106 | (let ((local-part (match-string 1)) |
| 107 | (tag (match-string 2))) |
| 108 | (push `(to ,(format "%s@odin\\.gg" local-part) |
| 109 | ,(format "crap.%s" tag)) |
| 110 | splits) |
| 111 | (push (cons tag local-part) senders))) |
| 112 | (forward-line))) |
| 113 | (setq mdw-odin-splits (nreverse splits) |
| 114 | mdw-odin-sender-alist (nreverse senders)))) |
| 115 | (mdw-update-odin-info) |
| 116 | |
| 117 | ;; Mail sent to `mdw-nospam-THING' should appear to come from this address. |
| 118 | (setq gnus-posting-styles |
| 119 | '(("^nnimap\\+distorted:crap\\." |
| 120 | (address (let* ((mailbox (substring gnus-newsgroup-name |
| 121 | (match-end 0))) |
| 122 | (entry (assoc mailbox mdw-odin-sender-alist))) |
| 123 | (if entry (concat (cdr entry) "@odin.gg") |
| 124 | (concat "mdw-nospam-" mailbox "@distorted.org.uk"))))) |
| 125 | ("^nnimap\\+[^:]+-chiark:" |
| 126 | ("X-mdw-Send-Mail" "chiark-smtp")) |
| 127 | ("^nnimap\\+google:" |
| 128 | (address "distorted.mdw@gmail.com") |
| 129 | ("X-mdw-Send-Mail" "gmail-smtp")))) |
| 130 | |
| 131 | ;; The actual splitting rules. |
| 132 | (setq nnmail-split-fancy |
| 133 | `(| |
| 134 | ;; Administrative boxes. |
| 135 | (to "\\<\\(root\\|postgres\\|ca\\|noc\\)@" "admin.misc" t) |
| 136 | (to "\\<\\(jukebox\\|nobody\\|darchive\\)@" "admin.misc" t) |
| 137 | (to "\\<\\(hostmaster\\)@" "admin.dns" t) |
| 138 | (to "\\<\\(news\\|newsmaster\\|usenet\\)@" "admin.news" t) |
| 139 | (to "\\<\\(postmaster\\|spamd\\|mailer-daemon\\)@" "admin.mail" t) |
| 140 | (to "\\<\\(irc\\|blight\\|ircbot\\)@" "admin.irc" t) |
| 141 | (to "\\<\\(www\\|webmaster\\|mtos\\)@" "admin.web" t) |
| 142 | (to "\\<\\(ftp\\|ftpadmin\\|mirror\\)@" "admin.ftp" t) |
| 143 | (to "\\\<\\(abuse\\|security\\)@" "admin.keep" t) |
| 144 | (from "cron daemon" "admin.misc") |
| 145 | (from "uucp@distorted\\.org\\.uk" "admin.uucp") |
| 146 | (from "darchive@.*\\.distorted\\.org\\.uk" "admin.misc") |
| 147 | (from "sales@aa\\.net\\.uk" "admin.aaisp") |
| 148 | (from "support@aa\\.net\\.uk" "admin.aaisp") |
| 149 | (from "bugs@distorted\\.org\\.uk" "admin.bugs") |
| 150 | (from "darchive@distorted\\.org\\.uk" "admin.darchive") |
| 151 | |
| 152 | ;; Colo and network provider. |
| 153 | (from "\\(accounts\\|support\\)@jump\\.net\\.uk" "keep.colo") |
| 154 | (from "\\(accounts\\|support\\)@aa\\.net\\.uk" "keep.aaisp") |
| 155 | |
| 156 | ;; Mailing lists, not split out earlier. |
| 157 | (to "python-list@python\\.org" "lists.python") |
| 158 | (to ,(concat "\\(jump-\\(announce\\|discuss\\|vps\\)\\)@" |
| 159 | "\\(lists\\.\\)?" "jump\\.net\\.uk") |
| 160 | "lists.\\1") |
| 161 | (to "cambridgecryptowhiskyclub@gmail\\.com" |
| 162 | "lists.cambridge-crypto-whisky") |
| 163 | (from ,(concat "@" "\\(" "liberty-human-rights" |
| 164 | "\\|" "libertyhumanrights" |
| 165 | "\\|" "libertymail" |
| 166 | "\\)" "\\.org\\.uk" "\\>") |
| 167 | "lists.liberty" t) |
| 168 | (from "@openrightsgroup\\.org\\>" "lists.org" t) |
| 169 | (from "@warwick\\.ac\\.uk\\>" "lists.warwick-uni" t) |
| 170 | (to "chiark-\\(motd\\|announce\\)@chiark\\.greenend\\.org\\.uk" |
| 171 | "lists.chiark-announce") |
| 172 | (to "sot@dotat\\.at" "lists.sot" t) |
| 173 | (any "clive-cambridge-gamers@nsict\\.org" "lists.nsict-games") |
| 174 | |
| 175 | ;; Per-sender addresses. |
| 176 | (to "\\<mdw-nospam-justgviing@" "crap.justgiving" t) |
| 177 | (to "\\<mdw-nospam-\\([^@]+\\)@" "crap.\\1" t) |
| 178 | (to "\\<mdw-nopspam-\\([^@]+\\)@" "crap.\\1" t) |
| 179 | |
| 180 | (to "\\(markw\\|mdw\\|mw\\)@odin\\.gg" "mail.misc") |
| 181 | ,@mdw-odin-splits |
| 182 | (to "\\([a-z0-9]+\\)@odin\\.gg" "crap.odin-misc") |
| 183 | |
| 184 | ;; Regular nags. |
| 185 | (from "\\(sealbot\\|cardbot\\)@ncipher\\.com" "nag.cardbot") |
| 186 | (from "\\<mailman-owner@" "nag.mailman" t) |
| 187 | |
| 188 | ;; Uninteresting mail. |
| 189 | (from "expiry@letsencrypt\\.org" "admin.letsencrypt") |
| 190 | |
| 191 | ;; Other splits I've not given a per-sender address. |
| 192 | (from "@\\([^.]+\\.\\)?aegon" "crap.aegon" t) |
| 193 | (from "@\\(.*\\.\\)?amazon\\." "crap.amazon" t) |
| 194 | (from "@\\(.*\\.\\)?primevideo\\." "crap.amazon" t) |
| 195 | (from "@cineworldmail\\.com\\>" "crap.cineworld" t) |
| 196 | (from "unlimited@cineworld\\.com\\>" "crap.cineworld" t) |
| 197 | (from "@\\(.*\\.\\)?gandi\\.net\\>" "crap.gandi" t) |
| 198 | (from "@accounts\\.google\\.com\\>" "crap.google" t) |
| 199 | (from "campaigns@jolla\\.com\\>" "crap.jolla" t) |
| 200 | (from "@\\(.*\\.\\)?lovefilm\\.com\\>" "crap.lovefilm" t) |
| 201 | (from "@mythic-beasts\\.com\\>" "crap.mythic-beasts" t) |
| 202 | (from "@\\([^.]+\\.\\)?nationwide" "crap.nationwide" t) |
| 203 | (from "nationwide@securesuiteemail\\.com\\>" "crap.nationwide" t) |
| 204 | (from "@action\\.openrightsgroup\\.org\\>" "crap.org" t) |
| 205 | (from "@picturehouses\\.co\\.uk\\>" "crap.picturehouse" t) |
| 206 | (from "@\\(.*\\.\\)?spotify\\(mail\\)?\\.com\\>" "crap.spotify" t) |
| 207 | (from "@thomann\\.de\\>" "crap.thomann" t) |
| 208 | (from "@tshirthell\\.com\\>" "crap.tshirt-hell" t) |
| 209 | (from "@wikimedia\\.org\\>" "crap.wikimedia" t) |
| 210 | |
| 211 | ;; Default. |
| 212 | "mail.misc")) |
| 213 | |
| 214 | ;;;-------------------------------------------------------------------------- |
| 215 | ;;; Where we get mail from. |
| 216 | |
| 217 | ;; Read mail on the IMAP server. |
| 218 | (setq gnus-secondary-select-methods |
| 219 | `((nnimap "distorted" |
| 220 | (nnimap-address "mail.distorted.org.uk") |
| 221 | (nnimap-user "mdw") |
| 222 | (nnimap-stream starttls) |
| 223 | (nnimap-inbox ("INBOX" "to.split")) |
| 224 | (nnimap-split-methods nnimap-split-fancy) |
| 225 | (nnimap-split-fancy ,nnmail-split-fancy) |
| 226 | (nnimap-unsplittable-articles (%Deleted))) |
| 227 | (nnimap "markw-distorted" |
| 228 | (nnimap-address "mail.distorted.org.uk") |
| 229 | (nnimap-user "markw") |
| 230 | (nnimap-stream starttls) |
| 231 | (nnimap-inbox ("INBOX" "to.split")) |
| 232 | (nnimap-split-methods nnimap-split-fancy) |
| 233 | (nnimap-split-fancy ,nnmail-split-fancy) |
| 234 | (nnimap-unsplittable-articles (%Deleted))) |
| 235 | (nnimap "mdw-chiark" |
| 236 | (nnimap-address "imap.dovecot.chiark.greenend.org.uk") |
| 237 | (nnimap-user "mdw") |
| 238 | (nnimap-stream starttls) |
| 239 | (nnimap-inbox ("INBOX" "to.split")) |
| 240 | (nnimap-split-methods nnimap-split-fancy) |
| 241 | (nnimap-split-fancy ,nnmail-split-fancy) |
| 242 | (nnimap-unsplittable-articles (%Deleted))) |
| 243 | (nnimap "mwooding-chiark" |
| 244 | (nnimap-address "imap.dovecot.chiark.greenend.org.uk") |
| 245 | (nnimap-user "mwooding") |
| 246 | (nnimap-stream starttls) |
| 247 | (nnimap-inbox ("INBOX" "to.split")) |
| 248 | (nnimap-split-methods nnimap-split-fancy) |
| 249 | (nnimap-split-fancy ,nnmail-split-fancy) |
| 250 | (nnimap-unsplittable-articles (%Deleted))) |
| 251 | (nnimap "google" |
| 252 | (nnimap-address "imap.gmail.com") |
| 253 | (nnimap-stream tls) |
| 254 | (nnimap-inbox ("INBOX" "to.split")) |
| 255 | (nnimap-split-methods nnimap-split-fancy) |
| 256 | (nnimap-split-fancy ,nnmail-split-fancy) |
| 257 | (nnimap-unsplittable-articles (%Deleted))))) |
| 258 | |
| 259 | ;; Send sent mail back to me. |
| 260 | (setq gnus-message-archive-method "mail" |
| 261 | gnus-gcc-mark-as-read t |
| 262 | gnus-message-archive-group "nnimap+distorted:mail.sent") |
| 263 | |
| 264 | ;;;----- That's all, folks -------------------------------------------------- |