去年,我为您带来了 19 天的 2019 年全新(对您而言)效率工具。今年,我将采取不同的方法:构建一个环境,让您在新的一年里更有效率,使用您可能已经或尚未使用的工具。
使用 Notmuch 索引您的电子邮件
昨天,我谈到了如何使用 OfflineIMAP 来同步我的邮件到我的本地机器。今天,我将讨论如何在阅读邮件之前预处理所有这些邮件。

Maildir 可能是目前最有用的邮件存储格式之一。并且有很多工具可以帮助您管理邮件。我一直使用的工具是一个名为 Notmuch 的小程序,它可以索引、标记和搜索邮件消息。还有几个程序可以与 Notmuch 协同工作,使处理大量邮件变得更加容易。
大多数 Linux 发行版都包含 Notmuch,您也可以在 MacOS 上获取它。Windows 用户可以通过 Windows Subsystem for Linux (WSL) 访问它,但这可能需要一些额外的调整。

在 Notmuch 首次运行时,它会询问您一些问题,并在您的主目录中创建一个 .notmuch-config 文件。接下来,通过运行 notmuch new 索引和标记您的所有邮件。您可以使用 notmuch search tag:new 进行验证;这将找到所有带有“new”标签的消息。这可能有很多邮件,因为 Notmuch 使用“new”标签来指示对其而言是新的消息,因此您需要清理它。
运行 notmuch search tag:unread 以查找任何未读消息;结果应该少很多邮件。要从您已经看过的消息中删除“new”标签,请运行 notmuch tag -new not tag:unread,这将搜索所有没有“unread”标签的消息,并从中删除“new”标签。现在,当您运行 notmuch search tag:new 时,它应该只显示未读邮件消息。
批量标记消息可能更有用,因为手动更新每次运行的标签可能非常繁琐。--batch 命令行选项告诉 Notmuch 读取多行命令并执行它们。还有 --input=filename 选项,它从文件中读取命令并应用它们。我有一个名为 tagmail.notmuch 的文件,我用它来为“new”邮件添加标签;它看起来像这样
# Manage sent, spam, and trash folders
-unread -new folder:Trash
-unread -new folder:Spam
-unread -new folder:Sent
# Note mail sent specifically to me (excluding bug mail)
+to-me to:kevin at sonney.com and tag:new and not tag:to-me
# And note all mail sent from me
+sent from:kevin at sonney.com and tag:new and not tag:sent
# Remove the new tag from messages
-new tag:new
然后我可以运行 notmuch tag --input=tagmail.notmuch 以在运行 notmuch new 后批量处理我的邮件消息,然后我也可以搜索这些标签。
Notmuch 还支持运行 pre-new 和 post-new 钩子。这些脚本存储在 Maildir/.notmuch/hooks 中,定义了在使用 notmuch new 索引新邮件之前 (pre-new) 和之后 (post-new) 运行的操作。在昨天的文章中,我谈到了使用 OfflineIMAP 从我的 IMAP 服务器同步邮件。从“pre-new”钩子运行它非常容易
#!/bin/bash
# Remove the new tag from messages that are still tagged as new
notmuch tag -new tag:new
# Sync mail messages
offlineimap -a LocalSync -u quiet
您还可以使用 Python 应用程序 afew,它与 Notmuch 数据库接口,为您标记诸如邮件列表和垃圾邮件之类的东西。您可以从 post-new 钩子以类似的方式运行 afew
#!/bin/bash
# tag with my custom tags
notmuch tag --input=~/tagmail.notmuch
# Run afew to tag new mail
afew -t -n
我建议在使用 afew 标记消息时,您不要使用 [ListMailsFilter],因为某些邮件处理程序会将晦涩难懂或彻头彻尾的垃圾 List-ID 标头添加到邮件消息中(我说的就是你,Google)。

在这一点上,任何支持 Notmuch 或 Maildir 的邮件阅读器都可以处理我的电子邮件。我有时会使用 alot,一个 Notmuch 专用客户端,在控制台中阅读邮件,但它不如其他一些邮件阅读器那么花哨。
在未来的日子里,我将向您展示一些其他的邮件客户端,它们很可能与您已经使用的工具集成。同时,查看一些与 Maildir 邮箱配合使用的其他工具——您可能会发现我尚未尝试过的隐藏的瑰宝。
评论已关闭。