Reading email (from gmail) in emacs 24

20,848

Solution 1

After trying many ways, I now use offlineimap to sync messages between my machine and the google server. Gnus then reads messages from the local machine. Postfix is used to send messages to the gmail smtp server. Virtues of this setup: reading/sending email does not involve waiting for servers while in gnus (fast), can read/send email while offline (passed to server when online again). If you preferred to use RMail, you could instead of gnus.

This is what I do on ubuntu 13.10.

offlineimap, run periodically puts mail into ~/Maildr/Gmail

contents of ~/.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 = [email protected]
remotepass = YourPass
folderfilter = lambda foldername: foldername in ['INBOX', 'Dev']
# Necessary as of OfflineIMAP 6.5.4
sslcacertfile = /etc/ssl/certs/ca-certificates.crt

gnus reads mail from ~/Maildir/Gmail

In emacs, the variable gnus-home-directory is set to "~/Documents/gnus". Contents of "~/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))))

Sending mail: emacs configuration variables: mail-user-agent is set to 'gnus-user-agent send-mail-function is set to 'sendmail-send-it user-mail-address is set to "[email protected]"

Trickiest thing is setting up Postfix, that is clearly described here:

Further comments to address questions:

The program offlineimap is controlled by the file ~/.offlineimaprc. When offineimap runs, it will keep information in the directory ~/.offlineimap. You can read the docs for explanation of how that all works.

Re: sending mail: In fact, I used to do send mail directly from emacs. This involved fiddling with a number of things. It turned out to be much easier to just let postfix handle it. For example, I use several different email accounts to send mail from in Gnus; I now let gnus know about this via posting-styles, and let postfix worry about which address should go to which server, and how.

Solution 2

Indeed mu4e is my choice: http://www.djcbsoftware.nl/code/mu/mu4e.html

edit: I also tried notmuchmail and fetched emails with mbsync (isync Debian package). mbsync got certificates support out of the box when offlineimap needed a configuration step. Some say it is more reliable. I prefer notmuch's display of conversations.

So mu4e uses offlineimap to fetch the mail, mu to index it and mu4e to show it in emacs.

One can even write rich text mails using org-mode ! It's still experimental but here's an example on how to include math formula and a plot written in python.

ps:

enter image description here

Solution 3

I'm not sure there's a "current authoritative way"?

Make sure you look at http://www.emacswiki.org/emacs/CategoryMail

mu4e sounded quite nice to me, but as I never got around to actually configuring this sort of thing for myself, I can't make any recommendations.

http://box.matto.nl/emacsgmail.html (for the Wanderlust client) is certainly relevant.

Solution 4

Like @Ehvince, I also recommend mu4e, even though I now use Gnus only. Mu4e is very easy to setup/use, convenient, fast and the search/sort capabilities are good.

While Wanderlust works, I found it a bit cumbersome in terms of installation. Once it was setup, I created a cheat sheet for keybindings that I kept nearby for a while. I'm not sure that it is actively maintained.

I've heard about Mew but never used it. One bonus point is that it seems to be installable directly as a package.

I came back to Gnus because it's bundled with Emacs, no additional software needed. My current setup includes: Mairix(for search), OfflineImap(to fetch mail). Like @Jeffrey, I also read news in Gnus.

Solution 5

As others have said, there is no one "authoritative" way to do this. Over the years, I've used VM, Gnus, MH-E and Wanderlust, not to mention a slew of non-emacs mail clients.

I'd love to try mu4e, based on all the great things I hear about it, but using offlineimap seems to defeat the purpose of IMAP, at least for using multiple computers. I don't really want to have to sync local copies of email on my work laptop, my home laptop and my desktop. (Actually, I do have a local repository on my desktop in MH format, so I could convert that to Maildir, but most of my mail reading is done from the laptops anyway.)

I'm currently using Gnus talking directly to an IMAP server. It sometimes pauses when fetching messages, but in general, it's pretty responsive. I found Wanderlust very hard to set up, and very slow once it worked.

Share:
20,848
Mittenchops
Author by

Mittenchops

Updated on July 09, 2022

Comments

  • Mittenchops
    Mittenchops almost 2 years

    What's the current authoritative way to check and send email in emacs 24?

    I've checked the following SO links:

    1. Setup for Gmail in Emacs VM
    2. https://superuser.com/questions/476714/how-to-configure-emacs-smtp-for-using-a-secure-server-gmail
    3. Which Emacs mail package should I use?

    And understand the packages smtpmail, rmail, are involved, as well as an .authinfo file.

    I have created an .authinfo file of the form:

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

    And have added the following to my init.el file:

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

    (As the second link, the Superuser one, said.)

    But when I run M-x rmail, it still connects to my computer's local email address, rather than my gmail. What do I need to set up to login and read/write email? (If you could include keystrokes, that would also be super helpful.)

    I'm running ubuntu 12.04 if that makes any difference.

  • lunaryorn
    lunaryorn over 10 years
    Are there specific reasons for Postfix in this setup? Why don't you use smptmail-send-it to send mail to GMail directly?
  • zakkak
    zakkak almost 10 years
    I strongly recommend trying isync as an alternative to offlineimap. It is much faster.
  • Sean Hagen
    Sean Hagen over 9 years
    Do you have a gist or something showing how the posting styles work? I've got three Gmail accounts I'd like to get set up in Gnus. I've already got Offlineimap working for all three, just have to make Gnus aware of them.
  • Jeffrey DeLeo
    Jeffrey DeLeo over 9 years
    Sean, if you post a question I can write up something detailed. Briefly: Each gmail account is a topic in gnus. You can set the posting-style for a topic to specify details. Example: ((posting-style (address "[email protected]") (organization "Bad at Best")))