基本思路,首先安装DavMail server版本,将exchange服务转换成标准服务,比如smtp, pop3, imap。
然后使用Emacs的mu4e连接DavMail的imap服务。
如何安装DavMail server请参考我之前的文章,已经做了更新:
DavMail server版配置
因为有了imap服务,可以采用我之前写的使用gnus访问gmail的方式,这样在emacs中就可以收邮件了。不过我决定尝试一种新的方法mu4e. 据说这个是很好的。
安装方法参考:
offlineimap下载邮件
使用之前需要先用offlineimap通过davmail server将公司邮箱中的邮件下载到本地。主要是需要配置一个文件~/.offlineimaprc
[general]
accounts = LeTV
maxsyncaccounts = 3
[Account LeTV]
localrepository = Local
remoterepository = Remote
[Repository Local]
type = Maildir
localfolders = ~/mail
[Repository Remote]
type = IMAP
remotehost = $dav_mail_server
remoteport = 1143
remoteuser = $your_account, no @
remotepass = $your_pwd
ssl = false
sslcacertfile = /etc/ssl/certs/ca-certificates.crt
maxconnections = 1
realdelete = no
注意:
1. 公司邮箱中自定义目录最好没有中文名称,否则运气不好会报错
2. 要创建本地目录 ~/mail
3. maxcoinnections 只能设置为1, 大于1的我都遇到报错,只能慢慢下载了
好,然后在~目录下,运行命令
offlineimap
我的邮件比较多,1万多封,5.1GB,等了一个晚上终于下载完成了。
索引本地邮件
好,现在邮件都在本地~/mail目录下了,来建立索引吧。
$ mu index -m ~/mail
indexing messages under /home/dean/mail [/home/dean/.mu/xapian]
- processing mail; processed: 11625; updated/new: 11625, cleaned-up: 0
mu: ignoring because bigger than 50000000 bytes: /home/dean/mail/INBOX/cur/1416665450_0.29886.dean-Aspire-V7-481G,U=5238,FMD5=7e33429f656f1e6e9d79b29c3f82c57e:2,S
/ processing mail; processed: 14550; updated/new: 14550, cleaned-up: 0
mu: ignoring because bigger than 50000000 bytes: /home/dean/mail/INBOX/cur/1416671339_0.29886.dean-Aspire-V7-481G,U=9646,FMD5=7e33429f656f1e6e9d79b29c3f82c57e:2,S
/ processing mail; processed: 23550; updated/new: 23550, cleaned-up: 0
mu: ignoring because bigger than 50000000 bytes: /home/dean/mail/Sent/cur/1416682079_0.29886.dean-Aspire-V7-481G,U=1719,FMD5=7f8c0283f16925caed8e632086b81b9c:2,S
/ processing mail; processed: 24750; updated/new: 24750, cleaned-up: 0
cleaning up messages [/home/dean/.mu/xapian]
| processing mail; processed: 24807; updated/new: 0, cleaned-up: 0
elapsed: 1 second(s), ~ 24807 msg/s
/ processing mail; processed: 24807; updated/new: 0, cleaned-up: 0
elapsed: 191 second(s), ~ 129 msg/s
配置emacs mu4e
在~/.emacs.d/init.el文件中,添加如下配置:
;; the exact path may differ -- check it
(add-to-list 'load-path "/usr/local/share/emacs/site-lisp/mu4e")
(require 'mu4e)
(setq mu4e-maildir "~/mail")
(setq mu4e-drafts-folder "/Drafts")
(setq mu4e-sent-folder "/Sent")
(setq mu4e-trash-folder "/Trash")
;; don't save message to Sent Messages, Gmail/IMAP takes care of this
(setq mu4e-sent-messages-behavior 'delete)
;; setup some handy shortcuts
;; you can quickly switch to your Inbox -- press ``ji''
;; then, when you want archive some messages, move them to
;; the 'All Mail' folder by pressing ``ma''.
(setq mu4e-maildir-shortcuts
'( ("/INBOX" . ?i)
("/[LeTV].Sent Mail" . ?s)
("/[LeTV].Trash" . ?t)
("/[LeTV].All Mail" . ?a)))
;; allow for updating mail using 'U' in the main view:
(setq mu4e-get-mail-command "offlineimap")
;; something about ourselves
(setq
user-mail-address "chenshu@letv.com"
user-full-name "Dean Chen"
message-signature
(concat
"Dean Chen\n"
"Email: chenshu@letv.com\n"
"Blog: blog.csdn.net/csfreebird\n"
"Big Data Tech Director of LeTV.com"
"\n"))
;; sending mail -- replace USERNAME with your gmail username
;; also, make sure the gnutls command line utils are installed
;; package 'gnutls-bin' in Debian/Ubuntu
(require 'smtpmail)
;; alternatively, for emacs-24 you can use:
(setq message-send-mail-function 'smtpmail-send-it
smtpmail-stream-type 'starttls
smtpmail-default-smtp-server "$dav_mail_server"
smtpmail-smtp-server "$dav_mail_server"
smtpmail-smtp-service 1025)
;; don't keep message buffers around
(setq message-kill-buffer-on-exit t)