How to Use gnus of Emacs to send and receive Gmail mail (English version)

Source: Internet
Author: User
Tags gpg imap gmail mail

Created: 2012-10-12 a updated:
2012-11-17 6 Author: Chen Bin

Gnus is a fine email client. but its learning curve is a little steep even for some geeks. I am a geek and I 've read all the gnus tutorials I cocould get from the Internet. for a very long time, I was still frustrated by gnus frequently. finally I decided
To list the most important tasks I need gnus to do And figure out all the details task by task.

That's why I write this tutorial which is short, simple and containing all the key points.

1 Let's forgive gnus.

Gnus is written in 1988. eclipsections in the Manual does not make sense for a modern email client (for example, what gnus manual CALS "summary buffer" is actually "List of emails ").

Gnus is fully docu. mented. That's actually a problem, though. Because it cocould take your into hours to dig out the useful key points from the manual.

2 Why gnus
  • Gnus is solid.
  • Need less resource on the hard disk and memory.
  • The search and filter is good.
  • It's embedded in Emacs.
  • Support different environment (say I want to see HTML email in Console window ).

3 A Quick Guide

See your http://www.emacswiki.org/emacs/GnusGmail on setting up gnus for Gmail.

Then you need input command "M-x gnus" to start gnus.

If the gnus properly set up, you will come to the "Group buffer" window which lists the email folders. but in gnus, the folder is named "group ". by default, the groups is
NotVisible. you need subscribe the groups. for example, my Gmail folder "inbox" is a group named "nnimap + Gmail: inbox" in "group buffer" and it's invisible by default !. If I don't subscribe that group, I can't read email in my inbox. I know
This is confusing. But this is the way of gnus. Check my next section to see how
SubscribeGroups.

After subscribing the inbox, the group inbox cocould still beInvisibleIf inbox does not contain unread emails. That makes no sense for a email client (OK for a news reader, though )! Anyway, the solution is simple, 'c-U 5 gnus-group-list-all-groupup'
Will get desired result. I assigned hotkey "O" to it. Here is my elisp code you coshould paste into your. emacs. See

Gnus manual on listing groups for more details.

(defun my-gnus-group-list-subscribed-groups ()  "List all subscribed groups with or without un-read messages"  (interactive)  (gnus-group-list-all-groups 5)  ) (add-hook 'gnus-group-mode-hook           ;; list all the subscribed groups even they contain zero un-read messages           (lambda () (local-set-key "o" 'my-gnus-group-list-subscribed-groups ))           )

In the "Group buffer", you can select a group (email folder) by pressing "RET" to see emails in that folder. but I stronugly suggest pressing "c-u RET" instead because your intention cocould be seeing all the emails instead the emails filtered by "smart" gnus.

After selecting a group and pressing "RET", you reach the "summary buffer" which is, as I said before, a list of your email.

Now everything is simple, you can press "RET" to see the email and use normail Emacs hotkeys for navigation. hotkey "Q" is for quitting "summary buffer ".

In summary, you only need remember "group buffer" for mail folders and "summary buffer" for mails.

That's all you need to know about gnus. Short tutorial, eh?

4 notes on using gnus for email4.1 how to search IMAP in gnus

"G" to search in current selected group at "group buffer ".

"//" To limit the emails by subject at "summary buffer". "limiting" is kind of searching mail locally ".

"/A" to limit the emails by author at "summary buffer ".

"/W" to cancel the current filter.

You can apply the limits sequentially and cancel them one by one using "/W"

BTW, I love "limiting" in gnus. See
Http://www.gnu.org/software/emacs/manual/html_mono/gnus.html#Limiting for more limiting tricks.

See http://sachachua.com/blog/2008/05/emacs-gnus-searching-mail/ for details.

4.2 subscribe groups

I admit this part of UI is actually far from elegant.

"A a" in "group buffer" to list all groups on all the Connected Server. it may take a while. I suggest pressing "L" to avoid querying data from all the servers if possible.

After getting the list of all subscribed/unsubscribed groups, press "U" to subscribe/Unsubscribe specific group.

I repeat, in order to see the emails in "inbox" folder/group, you need
Manually
Subscribe the group "inbox", right here, right now!

"L" to navigate back the default view of group buffer which you may find confusing, as I mentioned before. press "O" is much better if you uses my elisp code to show all the subscribed groups.

"G" to refresh groups list.

4.3 reply email

"R" to reply with quoted text. "R" to reply without quoted.

4.4 write new email

"A" or "M"

BTW, you don't need open gnus to compose a mail. You can type "C-x m" directly in Emacs.

4.5 attach a file

"C-"

4.6 send message/Email

"C-c". By default, emacs always use the hotkey "c-c" to submit/stop something.

4.7 refresh Summary BufferIn gnus (check new emails)

"/N", "M-x gnus-Summary-insert-New-articles"

4.8 see all the emails in "summary buffer" (important)

"C-u RET" in "group buffer", or "c-u m-g" in "summary buffer". That's the most important part of this article! That's why I want to write this article.

Check
Http://stackoverflow.com/questions/4982831/i-dont-want-to-expire-mail-in-gnus for the details.

5 my gnus configuration (for Gmail)

The ~ /. Gnus. El

; -*- Lisp -*-(require 'nnir);;@see http://www.emacswiki.org/emacs/GnusGmail#toc1(setq gnus-select-method '(nntp "news.gmane.org"));; ask encyption password once(setq epa-file-cache-passphrase-for-symmetric-encryption t)(setq smtpmail-auth-credentials "~/.authinfo.gpg");;@see http://gnus.org/manual/gnus_397.html(add-to-list 'gnus-secondary-select-methods             '(nnimap "gmail"                      (nnimap-address "imap.gmail.com")                      (nnimap-server-port 993)                      (nnimap-stream ssl)                      (nnir-search-engine imap)                      (nnimap-authinfo-file "~/.authinfo.gpg")                      ; @see http://www.gnu.org/software/emacs/manual/html_node/gnus/Expiring-Mail.html                      ;; press 'E' to expire email                      (nnmail-expiry-target "nnimap+gmail:[Gmail]/Trash")                      (nnmail-expiry-wait 90)                      )             )(setq-default  gnus-summary-line-format "%U%R%z %(%&user-date;  %-15,15f  %B%s%)\n"  gnus-user-date-format-alist '((t . "%Y-%m-%d %H:%M"))  gnus-summary-thread-gathering-function 'gnus-gather-threads-by-references  gnus-sum-thread-tree-false-root ""  gnus-sum-thread-tree-indent ""  gnus-sum-thread-tree-leaf-with-other "-> "  gnus-sum-thread-tree-root ""  gnus-sum-thread-tree-single-leaf "|_ "  gnus-sum-thread-tree-vertical "|")(setq gnus-thread-sort-functions      '(        (not gnus-thread-sort-by-date)        (not gnus-thread-sort-by-number)        )); NO 'passive(setq gnus-use-cache t)(setq gnus-use-adaptive-scoring t)(setq gnus-save-score t)(add-hook 'mail-citation-hook 'sc-cite-original)(add-hook 'message-sent-hook 'gnus-score-followup-article)(add-hook 'message-sent-hook 'gnus-score-followup-thread); @see http://stackoverflow.com/questions/945419/how-dont-use-gnus-adaptive-scoring-in-some-newsgroups(setq gnus-parameters      '(("nnimap.*"         (gnus-use-scoring nil))        ))(defvar gnus-default-adaptive-score-alist  '((gnus-kill-file-mark (from -10))    (gnus-unread-mark)    (gnus-read-mark (from 10) (subject 30))    (gnus-catchup-mark (subject -10))    (gnus-killed-mark (from -1) (subject -30))    (gnus-del-mark (from -2) (subject -15))    (gnus-ticked-mark (from 10))    (gnus-dormant-mark (from 5))))(setq  gnus-score-find-score-files-function       '(gnus-score-find-hierarchical gnus-score-find-bnews bbdb/gnus-score)       );; BBDB: Adress list(when (file-exists-p "/usr/share/emacs/site-lisp/bbdb")  (add-to-list 'load-path "/usr/share/emacs/site-lisp/bbdb")  (require 'bbdb)  (bbdb-initialize 'message 'gnus 'sendmail)  (setq bbdb-file "~/bbdb.db")  (add-hook 'gnus-startup-hook 'bbdb-insinuate-gnus)  (setq bbdb/mail-auto-create-p t        bbdb/news-auto-create-p t)  (defvar bbdb-time-internal-format "%Y-%m-%d"    "The internal date format.")  ;;;###autoload  (defun bbdb-timestamp-hook (record)    "For use as a `bbdb-change-hook'; maintains a notes-field called `timestamp'    for the given record which contains the time when it was last modified.  If    there is such a field there already, it is changed, otherwise it is added."    (bbdb-record-putprop record 'timestamp (format-time-string                                             bbdb-time-internal-format                                             (current-time))))    )(add-hook 'message-mode-hook          '(lambda ()             (flyspell-mode t)             (local-set-key "<TAB>" 'bbdb-complete-name)));; Fetch only part of the article if we can.  I saw this in someone;; else's .gnus(setq gnus-read-active-file 'some);; Tree view for groups.  I like the organisational feel this has.(add-hook 'gnus-group-mode-hook 'gnus-topic-mode);; Threads!  I hate reading un-threaded email -- especially mailing;; lists.  This helps a ton!(setq gnus-summary-thread-gathering-function      'gnus-gather-threads-by-subject);; Also, I prefer to see only the top level message.  If a message has;; several replies or is part of a thread, only show the first;; message.  'gnus-thread-ignore-subject' will ignore the subject and;; look at 'In-Reply-To:' and 'References:' headers.(setq gnus-thread-hide-subtree t)(setq gnus-thread-ignore-subject t); Personal Information(setq user-full-name "My Name"      user-mail-address "username@gmail.com"      ;message-generate-headers-first t      );; Change email address for work folder.  This is one of the most;; interesting features of Gnus.  I plan on adding custom .sigs soon;; for different mailing lists.;; Usage, FROM: My Name <work>(setq gnus-posting-styles      '((".*"         (name "My Name"          (address "username@gmail.com"                   (organization "")                   (signature-file "~/.signature")                   ("X-Troll" "Emacs is better than Vi")                   ))))); You need install the ClI brower 'w3m' and Emacs plugin 'w3m'(setq mm-text-html-renderer 'w3m)(setq message-send-mail-function 'smtpmail-send-it      smtpmail-starttls-credentials '(("smtp.gmail.com" 587 nil nil))      smtpmail-auth-credentials '(("smtp.gmail.com" 587 "username@gmail.com" nil))      smtpmail-default-smtp-server "smtp.gmail.com"      smtpmail-smtp-server "smtp.gmail.com"      smtpmail-smtp-service 587      smtpmail-local-domain "homepc");http://www.gnu.org/software/emacs/manual/html_node/gnus/_005b9_002e2_005d.html(setq gnus-use-correct-string-widths nil)(gnus-compile)

The ~ /. Authinfo. GPG

machine imap.gmail.com login username@gmail.com password my-secret-password port 993machine smtp.gmail.com login username@gmail.com password my-secret-password port 587

Please note. authinfo. GPG is a encrypted file. You must use Emacs to edit it. emacs will do the encryption/descryption on this file automatically. See
Http://emacswiki.org/emacs/EasyPG for technical details.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.