gnus-brief.txt: Brett Presnell (2005-04-01) SUBJECT: Some notes on getting started using gnus to read email from an IMAP server. DISCLAIMER: I barely know what I'm doing with gnus, so don't expect this to tell you everything you might want to know about it. UPDATE (2006-05-26): I am now using a snapshot of CVS emacs with a more recent gnus. The default agent behaviour in gnus has changed; the agent is now on by default for nnimap groups. This caused me no end of trouble until I disabled it. To do this, type "^" in the *Groups* buffer and in the server buffer type J-r after positioning the cursor on the line corresponding to your IMAP server. This turns off the agent for those groups. Typing J-a will turn it back on. At some point when I have time I may try to learn about the agent and configure it to work the way that I want. UPDATE (2009-11-15): Added something about K H for reading html messages. A NOTE ON TERMINOLOGY: gnus is really a news reader first and an email client second. So when reading email in gnus, you have to make the following translations: |---------+---------| | Email | Gnus | | Term | Term | |---------+---------| | folder | group | | message | article | |---------+---------| * CONFIGURATION ** Getting mail from IMAP Delete any references in your ~/.emacs file to mh-e or vm or rmail any other emacs email client. Put the following lines in your ~/.gnus file, making the obvious modifications (replace my username with yours and change the name of the "Sent" folder if you use something else. ;;-------------------------------------------------------------------- (setq gnus-select-method '(nnimap "mailhost" (nnimap-address "mailhost.stat.ufl.edu") (nnimap-stream ssl))) (setq gnus-message-archive-method '(nnimap "mailhost" (nnimap-address "mailhost.stat.ufl.edu") (nnimap-stream ssl))) (setq gnus-message-archive-group "Sent") ;;-------------------------------------------------------------------- The effect of the last group of lines is to add the line "Gcc: Sent" to the header of your outgoing messages, which saves a copy of the message in my "Sent" folder on the IMAP server. You can edit this line to change the default if you prefer something other than "Sent" (though this seems to be a common default) and you can can also put in any folder name you choose when composing a particular message. Unfortunately outside of gnus buffers, the Gcc line may not work (check this). This isn't a big problem though -- after all, you will almost always have gnus fired up when you're sending email. ** Sending mail via SMTP Add the following lines to either your ~/.emacs file or to your ~/.gnus file, again replacing my username with yours. (This stuff can go into your ~/.gnus file instead to keep all this together, but in that case it will not be read until you actually start gnus. Putting it into your ~/.emacs file allows you to compose and send an email without first starting gnus. Whichever you prefer is fine.) ;;-------------------------------------------------------------------- (setq mail-user-agent 'message-user-agent) (setq send-mail-function 'smtpmail-send-it ;; for `mail' message-send-mail-function 'smtpmail-send-it ;; for gnus/message smtpmail-default-smtp-server "eelpout.stat.ufl.edu" smtpmail-smtp-server "eelpout.stat.ufl.edu" smtpmail-default-smtp-service 25 smtpmail-smtp-service 25 smtpmail-auth-credentials '(("eelpout.stat.ufl.edu" 25 "presnell" nil)) smtpmail-starttls-credentials '(("eelpout.stat.ufl.edu" 25 nil nil)) ) ;;-------------------------------------------------------------------- Note: For this to work on my laptop I needed a copy of the latest smtpmail.el from the development (CVS) version of GNU Emacs (obviously this will not be necessary in some upcoming versions of emacs). When logged on to the stat system this is not needed because no authentication is required to send mail, but if running emacs/gnus on a remote machine (like your laptop), you will need it. If you don't already have a directory where you keep your personal lisp files, just create the directory ~/elisp on your laptop and copy the file ~presnell/elisp/smtpmail.el into this directory using scp, i.e., scp orca.stat.ufl.edu:~presnell/elisp/smtpmail.el ~/elisp Then add the line ;;-------------------------------------------------------------------- (setq load-path (cons "~/elisp" load-path)) ;;-------------------------------------------------------------------- to your ~/.emacs file. ** Reading old mail I decided to start clean on the IMAP server, so rather than copying all my old email over, I changed the name of my ~/Mail directory to ~/Mail.old. Adding the following lines to my ~/.gnus allows me to read these old messages using gnus. My folders are in "mbox" format, so I use gnus's "nnml" backend. For mh folders, you would change this to nnmh. I access these folders via "G f" in the *Groups* buffer. (This requires me to give the path to the folder, so I'm not sure that the "mail-sources" part of this is actually being used for anything.) You can also use this mechanism to move messages from your old folders onto the IMAP server (see the gnus manual for details). ;;-------------------------------------------------------------------- (setq gnus-secondary-select-methods '((nnml "local"))) (setq mail-sources '((directory :path "/home/presnell/Mail.old/"))) ;;-------------------------------------------------------------------- ** Other configuration matters *** Expiration time When you mark a message expirable, it normally is not actually deleted for 7 days. This is configurable using either the variable nnmail-expiry-wait or nnmail-expiry-wait-function. If you want messages marked expirable to be deleted immediately (i.e., as soon as you type M-g or ZG or quit the group summary buffer), add the following line to your .gnus file: (setq nnmail-expiry-wait 'immediate) *** Gnus-dired MIME integration If you use dired (emacs's file manager), you may want to add the following lines to your ~/.emacs (or to your ~/.gnus): ;;-------------------------------------------------------------------- (require 'gnus-dired) ;, isn't needed due to autoload cookies (add-hook 'dired-mode-hook 'turn-on-gnus-dired-mode) ;;-------------------------------------------------------------------- Then in dired buffers you can attach all marked files to a message with the command M-x gnus-dired-attach (C-c RET C-a). This is really handy. * GETTING STARTED READING MAIL IN GNUS M-x gnus : fire up gnus Of course in any gnus buffer you can browse the menus and/or do "C-h m" to see the "*Help*" for the mode. This will show you a lot of things that you can do, including a lot of the default key mappings. There is also refcard for gnus with a long list of keys and commands that you can use (ask me for a copy). For more details, consult the info pages for gnus (C-h i m gnus or via the menu, Help -> Manuals -> Browse manuals with info). ** In the *Group* buffer: g : get new news/mail u : subscribe/unsubscribe toggle U : subscribe (even to unseen groups/folders) l : list groups with new articles/messages L : list all subscribed and most unsubscribed groups/folders (but see below for limiting by levels) : read group (unread and ticked articles) C-u : read all articles in the group (including ones marked read) C-k : kill group C-y : yank group (with kill, useful for reordering list of groups) G DEL : remove group from the server (gnus-group-delete-group) DEL is the Backspace or the Delete key on most keyboards. Note that to really remove the group from the IMAP server, you have to make FORCE non-nill by giving a prefix, i.e., by typing M-1 G-DEL. ^ : opens a server buffer. Once there you can open the server ( or with the cursor on the appropriate server) to see all its groups and read them "ephemerally". *** Levels (useful for limiting which groups/folders are displayed) S-l : set level of group/folder (levels are useful for limiting which folders/groups are displayed) A-l : list groups/folders on a given level L : List all groups/folders with level ARG or lower (you input the ARG in the usual emacs way, e.g., by preceding the L with M-1 or M-2 to choose levels 1 or 2, respectively. ** In a Summary buffer (for a particular group): : read/scroll article forward : scroll article backward r : reply (R includes a copy of the current article) R : reply including a copy of the current article f : followup ("wide" reply to all recipients of current article) F : followup including a copy of the current article /N : get new news/mail *** You can mark and unmark articles in various ways: E : mark the message expirable (for deletion) # : mark the article for processing (e.g., for moving) M-# : unmark as processable (remove the "#") ! : "tick" the current article (I use this for email I want to look at each time I visit the folder) M-u : clear marks (removes the "tick") MC : mark all articles as read (that's capital M followed by capital C, and NOT M-C (meta-C)) *** B is for "backend" (for us this is nnimap, the gnus IMAP backend) M-g : (or ZG) gnus-summary-rescan-group updates stuff, getting new messages and removing deleted messages (but may alter the view more than you want) Bm : move the current or marked article(s) to another folder B : delete current or marked article(s) (careful, anything marked with a # will be deleted) B M-C-e : gnus-summary-expire-articles-now deletes expirable messages immediately *** You can limit the articles that you view (there are a lot more of these): /o : show old articles (by default gnus shows you only new and "ticked" articles /a : show only articles from a particular author /s : show only articles with subjects matching a regexp /x : lets you choose the header to limit by (the default is the "To" header, so this is useful for looking through the messages you have sent to a particular recipient) Limit the summary buffer to articles that match an 'extra' header. There are also various ways to sort the articles. See the "Gnus -> Sort" menu, which also gives the keystrokes. If you don't already pre-sort your incoming email by some other mechanism, you might be interested in gnus "splitting." Read the gnus manual (info) for more on this. *** READING MIME You can things for reading messages with MIME attachments on the "Article -> MIME" menu. One thing that I have found useful when dealing with a message with several attachments that I want to save (e.g., a message from a journal editor) is "X m" (extract all parts). Note that this also saves the body of the message to a file. *** READING HTML You can set things up to use w3m, which is an emacs web browser, but these days I just type K H (capital K followed by capital H) to send the article to my default web browser (firefox). * COMPOSING A MESSAGE In a gnus buffer type "m", outside of gnus, type "C-x m". Many of the keystrokes you know from another emacs email client should work here, but until you have learned the keystrokes for the commands you use often, you can find what you need in the menus or via "C-h m". Note also that gnus will read your .mailrc file and expand any aliases you have there. ** Adding attachments The basic keystroke for adding a MIME attachment is C-cC-a. If you have gnus-dired configured as described above, you can attach all marked files in a dired buffer to a message with the command M-x gnus-dired-attach (C-c RET C-a). If you are already composing a new message or messages, you will be queried for whether the file(s) should be attached to an existing message buffer. If you answer no to this query (or if there is no existing message buffer), a new message is begun with the marked file(s) attached. Otherwise the file(s) are attached to the existing message or if there is more than one message being composed, you are queried for the message to which they should be attached. * REPLYING TO A MESSAGE To reply to a message type r (reply to sender) or R (also yanks the message body) or f (reply to all) or F. After that you're just composing a message, but the following additional commands are handy: `C-c C-e' Elide the text between point and mark (`message-elide-region'). The text is killed and replaced with the contents of the variable `message-elide-ellipsis'. The default value is to use an ellipsis (`[...]'). `C-c M-k' Kill the address under point. `C-c C-v' Delete all text in the body of the message that is outside the region (`message-delete-not-region'). `M-RET' Insert four newlines, and then reformat if inside quoted text. Here's an example: > This is some quoted text. And here's more quoted text. If point is before `And' and you press `M-RET', you'll get: > This is some quoted text. * > And here's more quoted text. `*' says where point will be placed.