阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

用Emacs接收Exchange邮件

120次阅读
没有评论

共计 4045 个字符,预计需要花费 11 分钟才能阅读完成。

基本思路,首先安装 DavMail server 版本,将 exchange 服务转换成标准服务,比如 smtp, pop3, imap。

然后使用 Emacs 的 mu4e 连接 DavMail 的 imap 服务。

如何安装 DavMail server 请参考我之前的文章,已经做了更新:

DavMail server 版配置

因为有了 imap 服务,可以采用我之前写的使用 gnus 访问 gmail 的方式,这样在 emacs 中就可以收邮件了。不过我决定尝试一种新的方法 mu4e. 据说这个是很好的。

安装方法参考

http://www.djcbsoftware.nl/code/mu/mu4e/Installation.html#Installation

offlineimap 下载邮件

使用之前需要先用 offlineimap 通过 davmail server 将公司邮箱中的邮件下载到本地。主要是需要配置一个文件~/.offlineimaprc

http://www.djcbsoftware.nl/code/mu/mu4e/Gmail-configuration.html#Gmail-configuration

[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)

;;———————————————————-
;; —- END Email client —-
;;———————————————————-
(put ‘erase-buffer ‘disabled nil)

然后启动 emacs, M-x 后运行命令:mu4e,看到如下画面:

用 Emacs 接收 Exchange 邮件

为 Emacs 配置 newLISP 开发环境 http://www.linuxidc.com/Linux/2013-01/78463.htm

手把手教你学会 Emacs 主题配置 http://www.linuxidc.com/Linux/2012-10/72342.htm

Ubuntu 下编译安装 Emacs23  http://www.linuxidc.com/Linux/2009-08/21348.htm

手把手教你学会 Emacs 定制 http://www.linuxidc.com/Linux/2012-10/72341.htm

如何在 GNU Emacs 环境下编译并运行 C /C++ 程序?http://www.linuxidc.com/Linux/2012-08/68299.htm

Ubuntu 安装 Emacs 出现到依赖问题及解决方案 http://www.linuxidc.com/Linux/2014-08/104975.htm

正文完
星哥说事-微信公众号
post-qrcode
 
星锅
版权声明:本站原创文章,由 星锅 2022-01-20发表,共计4045字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中