[Techtalk] Mail handling & filtering

Akkana Peck akkana at shallowsky.com
Tue Sep 28 16:35:56 UTC 2021


Terry M. Roy via Techtalk writes:
> I have a couple of Gmail accounts that receive mail containing various
[ ... ]
> I'd like a way to process those emails independently of the mail client I'm
> using since I am often out and reviewing them via iPhone.
> 
> What I envision: Gmail is accessed through IMAP, the messages are filtered,
> appropriate ones are discarded and mail is synced back via IMAP to Gmail to
> remove the discarded messages so it will update my phone & tablet.
> 
> I currently have a Debian server I can set this up on that's on 24/7.
> 
> I've looked at mbsync for accessing the messages and procmail for filtering
> but am not sure if mbsync can be used with procmail. Everything I've found

I use mbsync, but in the more normal way, to get a local copy of a
server's IMAP folders which I can then access with mutt. I don't
know of any way to get mbsync to trigger something like procmail.

Do the messages need to stay on gmail? If not, one thing you could
do is a second level of IMAP:

On the Debian server, periodically run fetchmail (which does work
with procmail) to suck messages from Gmail though procmail into a
folder setup on your server, deleting/expunging them from Gmail.

Then run dovecot on those folders to make them available via IMAP 
to your server, which you can access from anywhere.

Would that do what you need?

Another possibility to investigate is notmuch. I think its original
purpose was searching within maildirs, but I'm increasingly hearing
from people who use it as a mail user agent, and it apparently can
also do filtering, so you might be able to run notmuch to filter the
folders you pulled down from Gmail using mbsync. I'm still vague on
exactly what notmuch can do: I keep wanting to try it but it
requires converting my whole mail archive from mbox to maildir and I
haven't quite come to terms with that. (My incoming folder tree is
already maildir because of mbsync, but I have many years of mbox
archives too.) So I have no personal experience, just that it seems
increasingly popular for searching/sorting mail and apparently is
very flexible and can do a lot of different things.

        ...Akkana



More information about the Techtalk mailing list