💾 Archived View for lunacb.house › blog › 2023-11-08.gmi captured on 2024-02-05 at 09:34:35. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-11-14)
-=-=-=-=-=-=-
created: 2023-11-08 15:25:45 UTC
modified: 2023-11-09 14:59:50 UTC
I started subscribing to a few mailing lists, and since that meant I might actually be using my email for something, I thought it'd be good to figure out a way to filter my emails into different folders so they don't get too gross and cluttered. After looking around I found imapfilter, which turned out to be very easy to use. You can write a lua script that'll scan through your emails and do things to them like deleting them or moving them to different folders. I wrote a few utility functions and made a nice-loooking configuration script with it:
function convert(map) local res = {} for mbox, contents in pairs(map) do if type(mbox) == "string" then for index, pattern in ipairs(contents) do res[pattern] = mbox end for k, v in pairs(convert(contents)) do res[k] = mbox .. "/" .. v end end end return res end function filter_by_originator(account, map) map = convert(map) for origin, mailbox in pairs(map) do results = account.INBOX:match_field("from", origin) + account.INBOX:match_field("sender", origin) + account.INBOX:match_field("reply-to", origin) results:move_messages(account[mailbox]) end end function do_luna(account) filter_by_originator(account, { junk = { "News@InsideApple.Apple.com", "no-reply@email.patreon.com", "no-reply@mail.goodreads.com", "no-reply@substack.com", "no-reply@twitch.tv", "noreply@updates.itch.io", "team@info.digitalocean.com", }, pr = { "NoReply.ODD@dhl.com", "account@twitch.tv", "appleid@id.apple.com", "bingo@patreon.com", "donotreply_odd@dhl.com", "expiry@letsencrypt.org", "no-reply@patreon.com", "noreply@bandcamp.com", "noreply@github.com", "renewals@namecheap.com", "support@buyee.jp", "support@digitalocean.com", "support@itch.io", "support@namecheap.com", "support@porkbun.com", }, info = { "gitlab@gitlab.freedesktop.org", "no-reply@disroot.org", }, news = { "erininthemorn@substack.com", }, lists = { lua = { ".*@lists.lua.org" }, hare_users = { ".*hare-users@lists.sr.ht" }, hare_announce = { ".*hare-announce@lists.sr.ht" }, } }) end do_luna(IMAP { server = "disroot.org", username = "lunacb", password = ":3", port = 993, ssl = "auto", })