在Emacs 24中阅读Gmail邮件

42

在 Emacs 24 中,确认和发送电子邮件的权威方式是什么?

我已经查看了以下 StackOverflow 链接:

  1. 设置 Emacs VM 中的 Gmail
  2. 如何配置 Emacs SMTP 以使用安全服务器 Gmail
  3. 我应该使用哪个 Emacs 邮件包?

我了解到涉及到以下包smtpmailrmail和一个 .authinfo 文件

我创建了一个 .authinfo 文件,内容如下:

machine mail.example.org port 25 login myuser password mypassword

并将以下代码添加到我的 init.el 文件:

(setq smtpmail-stream-type 'ssl)
(setq smtpmail-smtp-server "smtp.gmail.com")
(setq smtpmail-smtp-service 465)

(就像第二个链接,即Superuser所说的那样。)

但是当我运行M-x rmail时,它仍然连接到我的计算机本地的电子邮件地址,而不是我的gmail。我需要设置什么才能登录并阅读/写入电子邮件?(如果您能包括按键操作,那也将非常有帮助。)

如果这有任何区别,我正在运行ubuntu 12.04。


5
SMTP是用于发送邮件的协议,而非阅读邮件(阅读邮件需要使用IMAP或POP3)。以下是一些建议:http://superuser.com/questions/69504/getting-gmail-in-emacs - steckerhalter
5个回答

29
尝试了多种方法后,我现在使用offlineimap来同步我的电脑和谷歌服务器之间的邮件。然后,Gnus从本地机器上读取邮件。使用Postfix将邮件发送到Gmail SMTP服务器。这种设置的优点是:在gnus中阅读/发送电子邮件不涉及等待服务器(快速),可以在离线时阅读/发送电子邮件(联机后传递给服务器)。如果你喜欢使用RMail,你可以用它代替gnus。
这是我在Ubuntu 13.10上所做的。
定期运行的offlineimap会将邮件放入~/Maildr/Gmail中。
~/.offlineimaprc的内容:
[general]
# List of accounts to be synced, separated by a comma.
accounts = Gmail
maxsyncaccounts = 2

[Account Gmail]
# Identifier for the local repository; e.g. the maildir to be synced via IMAP.
localrepository = Gmail-local
# Identifier for the remote repository; i.e. the actual IMAP, usually non-local.
remoterepository = Gmail-remote
# Status cache. Default is plain, which eventually becomes huge and slow.
status_backend = sqlite

[Repository Gmail-local]
type = Maildir
localfolders = ~/Maildir/Gmail

[Repository Gmail-remote]
type = Gmail
remoteuser = YourName@gmail.com
remotepass = YourPass
folderfilter = lambda foldername: foldername in ['INBOX', 'Dev']
# Necessary as of OfflineIMAP 6.5.4
sslcacertfile = /etc/ssl/certs/ca-certificates.crt

gnus从~/Maildir/Gmail中读取邮件。

在emacs中,变量gnus-home-directory被设置为"~/Documents/gnus"。"~/Documents/gnus/.gnus"的内容如下:

(setq gnus-select-method
      '(nntp "localhost")) ; I also read news in gnus; it is copied to my local machine via **leafnode**

(setq gnus-secondary-select-methods
      '((nnmaildir "GMail" (directory "~/Maildir/Gmail")) ; grab mail from here
    (nnfolder "archive"
      (nnfolder-directory   "~/Documents/gnus/Mail/archive") ; where I archive sent email
      (nnfolder-active-file "~/Documents/gnus/Mail/archive/active")
      (nnfolder-get-new-mail nil)
      (nnfolder-inhibit-expiry t))))

发送邮件: emacs配置变量: mail-user-agent设置为'gnus-user-agent' send-mail-function设置为'sendmail-send-it' user-mail-address设置为"YourName@gmail.com"

最棘手的事情是设置Postfix,这在这里有明确的描述:

进一步的评论以回答问题:

程序offlineimap由文件~/.offlineimaprc控制。当offineimap运行时,它将在目录~/.offlineimap中保留信息。您可以阅读文档以了解其工作原理的解释。

关于发送邮件: 实际上,我曾经直接从emacs发送邮件。这涉及到许多琐碎的事情。结果证明,让postfix处理它要容易得多。例如,我在Gnus中使用几个不同的电子邮件帐户发送邮件; 现在我通过posting-styles告诉gnus这一点,并让postfix担心哪个地址应该发送到哪个服务器以及如何处理。


1
在这个设置中,使用Postfix有具体的原因吗?为什么不直接使用smptmail-send-it将邮件发送到GMail? - user355252
2
我强烈推荐尝试使用isync作为离线imap的替代方案。它速度更快。 - zakkak
你有没有一个示例或者什么东西可以展示一下发布样式是如何工作的?我有三个 Gmail 账户,我想在 Gnus 中设置它们。我已经让 Offlineimap 为这三个账户工作了,现在只需要让 Gnus 意识到它们即可。 - Sean Hagen
Sean,如果你发一个问题,我可以写一份详细的东西。简单来说:每个Gmail帐户都是gnus中的一个主题。您可以设置主题的发布样式以指定详细信息。例如:((posting-style (address "address_one@gmail.com") (organization "Bad at Best"))) - Jeffrey DeLeo

19

实际上,mu4e 是我的选择:http://www.djcbsoftware.nl/code/mu/mu4e.html

编辑:我还尝试过notmuchmail并使用mbsyncisync Debian包)获取电子邮件。 mbsync在离线imap需要进行配置步骤时即可支持证书。有人称其更加可靠。 我喜欢notmuch的对话显示。

因此,mu4e使用离线imap获取邮件,mu对其进行索引,并在emacs中显示它。

甚至可以使用org-mode编写富文本邮件!虽然仍处于实验阶段,但这里有一个示例,说明如何包含数学公式和用Python编写的图表。

附:

这里输入图片描述


4

4
就像@Ehvince所说,我也推荐使用mu4e,尽管我现在只使用Gnus。 Mu4e非常易于设置和使用,方便快捷,并且具有良好的搜索/排序功能。
虽然Wanderlust可以正常工作,但我发现安装有点麻烦。一旦它被设置好了,我就创建了一个快捷键绑定的备忘单,并在附近保存了一段时间。我不确定它是否正在积极维护。
我听说过Mew,但从未使用过。一个加分点是它似乎可以直接安装为一个软件包。
我回到Gnus,因为它与Emacs捆绑在一起,不需要额外的软件。我的当前设置包括:Mairix(用于搜索),OfflineImap(用于获取邮件)。像@Jeffrey一样,我也在Gnus中阅读新闻。

3
正如其他人所说,没有一种“权威”的方法来做这件事。多年来,我使用过VM、Gnus、MH-E和Wanderlust,更不用说一堆非emacs邮件客户端了。
我很想尝试mu4e,因为我听到了很多关于它的好消息,但使用offlineimap似乎有违IMAP的初衷,至少对于使用多台计算机的用户而言是如此。我真的不想在我的工作笔记本电脑、家用笔记本电脑和台式机上同步邮件的本地副本。(实际上,我在我的台式机上有一个MH格式的本地存储库,所以我可以将其转换为Maildir,但我的大部分邮件阅读都是从笔记本电脑上进行的。)
我目前正在使用直接连接IMAP服务器的Gnus。它有时会在获取邮件时暂停,但总体上,它相当灵敏。我发现Wanderlust很难设置,并且一旦设置成功后速度也很慢。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接