I use imapfilter
to sort my email.
imapfilter
is configured using lua, which both gives you infinite possibilities, but also no premade solutions.
Here’s a couple I came up with.
GitHub sends all notifications from notifications@github.com
, but encodes the project name in the TO
header.
So we fetch the TO
field of every email, parse out the project name.
For some reason, I have at least one project where the project name is quoted, so we remove the quotes.
For perfomance reason, we then collect all emails by project and move them to a organisation/projectname
folder struture.
function filter_github_email(box, target_account)
= box:contain_from("notifications@github.com")
messages
= {}
actions for _, message in ipairs(messages) do
, uid = table.unpack(message)
mailbox= box[uid]:fetch_field("TO")
to = string.match(to, 'To: ([%S]+)')
project = project:gsub('"', '')
project_scrubbed = "GitHub/" .. project_scrubbed
target_mailbox
if not actions[target_mailbox] then
[target_mailbox] = Set {}
actionsend
table.insert(actions[target_mailbox], message)
end
for mailbox, msgs in pairs(actions) do
:move_messages(target_account[mailbox])
msgsend
end
(account.INBOX, account) filter_github_email