After 10+ years I'm in the process of retiring my mail-host. In the future I'll no longer be running exim4/dovecot/similar, and handling my own mail. Instead it'll all go to a (paid) Google account.
It feels like the end of an era, as it means a lot of my daily life will not be spent inside a single host no longer will I run:
ssh [email protected]
I'm still within my Gsuite trial, but I've mostly finished importing my vast mail archive, via mbsync.
The only outstanding thing I need is some scripting for the mail. Since my mail has been self-hosted I've evolved a large and complex procmail configuration file which sorted incoming messages into Maildir folders.
Having a quick look around last night I couldn't find anything similar for the brave new world of Google Mail. So I hacked up a quick script which will automatically add labels to new messages that don't have any.
Finding messages which are new/unread and which don't have labels is a matter of searching for:
is:unread -has:userlabels
From there adding labels is pretty simple, if you decide what you want. For the moment I'm keeping it simple:
- If a message comes from
"Bob Smith" <[email protected]>
- I add the label "
bob.smith
". - I add the label "
example.com
".
- I add the label "
Both labels will be created if they don't already exist, and the actual coding part was pretty simple. To be more complex/flexible I would probably need to integrate a scripting language (oh, I have one of those), and let the user decide what to do for each message.
The biggest annoyance is setting up the Google project, and all the OAUTH magic. I've documented briefly what I did but I don't actually know if anybody else could run the damn thing - there's just too much "magic" involved in these APIs.
Anyway procmail-lite for gmail. Job done.
Tags: dovecot, exim, gmail, golang, gsuite, maildir, procmail 5 comments