Today, we will see how to read and mails locally for fast search. Using
the powerful notmuch
, a local database will be created. By default,
notmuch
do not move or remove mails but just operate on tags. 5 steps
are needed:
- synchronize mail locally (
mbsync
) - index and tag mail (
notmuch
) - use an email client (emacs interface to
notmuch
), withmsmtp
for sending mail - move mails according to the tags (
afew
)
Once everything is setup, you will only need to run notmuch new
.
Updated on: 2025-02-20
Synchronize mail locally (mbsync)
Mbsync setup with an Infomaniak email account with the following
~/.mbsyncrc
. The list of folders is hardcoded in Patterns
:
|
|
Try it with mbsync -a
.
Index and tag mail (notmuch
)
For faster search, we create a local database for mails. This adds
another layer on our stack as we will need to synchronize the database
with locat files. notmuch
do not delete files ! Configuration is
simple:
|
|
Use an email client (notmuch-emacs
)
with doom-emacs
, enable the notmuch
interface in
~/.config/doom.d/init.el
|
|
Some setup is required for inbox: I want mails tagged as "new" only.
Then archiving and deleting should remove the appropriate tags (note:
afew should) Deleting is done either with d
(adds +deleted
) or
SPC m d
(call +notmuch-delete-tags
defined below).
|
|
msmtp
for sending mail
A simple version with password stored in plain text: ~/.msmtprc
defaults auth on tls on tls_trust_file /etc/ssl/certs/ca-certificates.crt logfile ~/.msmtp.log account infomaniak host mail.infomaniak.com port 465 tls_starttls off from $EMAIL user $EMAIL password $PASS account default: infomaniak
Change permissions
|
|
Test it with :
|
|
Putting everything together
Create ~/mail/.notmuch/hooks/pre-new
with
#!/bin/sh mbsync -a
Create ~/mail/.notmuch/hooks/post-new
with
#!/bin/sh afew --new --tag afew --new --move
Make both files executables with chmod +x
. Then notmuch new
will
sync first, add tags and use afew
for cleanup !