可能得益于昨天 Python 折腾了类似功能,以及 imap.el
清晰的文档,刚刚很快就找出了有几封未读。下面返回的数字表示 Message 的 ID,所以推断出有 5 封未读邮件:
(let ((server "imap.fastmail.com")
(user "[email protected]")
(pass "xxxxxxxxxxxxxxx"))
(with-current-buffer (imap-open server nil 'tls)
(imap-authenticate user pass)
(imap-mailbox-select "INBOX" 'read-only)
(imap-search "UNSEEN")))
;; => (652 653 654 655 656)
还可以抓取邮件的本身,但还不清楚怎么解析邮件,比如抓取主题之类的:
(with-current-buffer " *imap* imap.fastmail.com:0"
(setq s (imap-fetch 652 "RFC822.PEEK" 'RFC822)))
最后关闭连接:
(with-current-buffer " *imap* imap.fastmail.com:0"
(imap-close))
imap.el
的文档(注释部分)给出了例子,很有帮助。