mutt 用的久了,邮件也越来越多。虽然 Google Desktop 的索引和查找功能很不错,但是最后查看附件或者回复邮件的时候,依然离不开终端,离不开 mutt。

难道命令行终端里面就没有一款能够索引本地邮件的工具吗?有,而且还有不少:

  • mairix is a program for indexing and searching email messages stored in maildir, MH or mbox folders.
  • namazu is a full-text search engine intended for easy use.
  • mu is a tool for dealing with e-mail messages stored in the Maildir-format.
  • nmzmail is a tool to use the namazu search engine from within the mutt mail client to search mail stored in maildir folders.
  • notmuch is a system for indexing, searching, reading, and tagging large collections of email messages in maildir or mh format.

看了这里1的介绍,就先试用了他推荐的 notmuch,谁知道索引创建了 20 分钟还没完,还 “that’s not much mail” 呢,鄙视他。

11896% notmuch new
Found 76646 total files (that's not much mail).
Processed 58163 total files in 21m 37s (44 files/sec.).
Added 54343 new messages to the database.

就在这漫长的 20 分钟,我又试了一下 mu (v0.7.2),只用了不到 5 分钟,1.1G 的邮件全部搞定。而且创建索引的时候,每 2000 封一跳让人很有快感。

11922% mu index -m /sun/maildir
mu: Indexing messages from /sun/maildir
mu: Database: /sun/.mu/xapian
/ processing mail; processed: 76648; updated/new: 76648, cleaned-up: 0

我记得刚开始用 mutt 之后的不久,我曾经找过这些工具,但这些工具的最大问题不是速度,而是不支持中文,所以后来没办法才用的 Google Desktop。

用 mu 搜索中文,果然还是不行。无意间看到了 mu 的处理日志,里面有一些编码转换的警告,再看了一些代码,里面的确有用 glib 转换编码。

抱着试试看的心情下载了最新版 v0.9.7,编译、安装,重建索引,这次的索引创建过程让人更加有快感,50000 封一跳,只用了不到 2 分钟,我了个去。

12021% ./bin/mu index --rebuild
mu: indexing messages under /sun/maildir [/sun/.mu/xapian]
/ processing mail; processed: 76648; updated/new: 76648, cleaned-up: 0
mu: elapsed: 103 second(s), ~ 744 msg/s
mu: cleaning up messages [/sun/.mu/xapian]
mu: elapsed: 1 second(s), ~ 76648 msg/s

虽然用新版的 mu 能搜索中文,但是因为 mu 用单词作为搜索单元,又以空格来区分单词,所有没有被空格隔开的中文就悲剧了。英文好的同学能帮忙报个 BUG 就好了。