Skip to content

Latest commit

 

History

History
250 lines (216 loc) · 8.78 KB

starter-kit-gnus.org

File metadata and controls

250 lines (216 loc) · 8.78 KB

Starter Kit Gnus

This is part of the Emacs Starter Kit.

Starter Kit Gnus

Configuration for the notoriously difficult to configure Gnus email client

IMAP

Based on the instructions at emacswiki:GnusGmail.

to use this file:

  1. personal information in this file (specifically in the code blocks which will be tangled in the next step) globally replace “your-name” with your gmail username, and “your-password” with your gmail password.
  2. tangle this file Run the org-babel-tangle command to extract the code embedded in this file into a starter-git-gnus-imap.el file which can be added to your configuration, and a ~/.authinfo file which will be used by gnus.
  3. load this configuration If you have a recent version of Org-mode (i.e. after 7.0) or are using the literate Emacs Starter Kit, then this file can be loaded directly using the org-babel-load-file function, or by placing it in your load path (if you’re using the starter kit).

    Alternately ensure that the gnus-gmail.el file generated by the previous step is loaded by your configuration.

  4. fire up gnus This can be done with the command M-x gnus
  5. view your mail After gnus boots up you will see the “Group Buffer” (see Group-Buffer). Each line is a mail “Group”, hit SPACE or ENTER on a group to view it’s contents. You should see an “INBOX” group which contains the mail in your gmail account. If not, you can jump to the “INBOX” group by
    • pressing j for “jump”
    • tab completing the name “INBOX”
    • pressing U for “unkill” meaning this will now always be displayed in your Group buffer when you have new mail
  6. customize Gnus has unrivalled capacity for customization. Once your comfortable with basic usage, take some time to browse through the very readable Gnus Manual to learn untold tricks (see also Starter-kit-gnus:Customizations).

saving mail locally

Where your mail will be saved locally default value will be ~/gmail.

(require 'gnus)
(setq nnml-directory "~/gmail")
(setq message-directory "~/gmail")

All Gmail groups will be ignored by the default value of gnus-ignored-newsgroups, so let’s change that default value.

(setq gnus-ignored-newsgroups "^to\\.\\|^[0-9. ]+\\( \\|$\\)\\|^[\”]\”[#’()]")

getting mail

Set Gmail as the primary source for incoming mail (Gnus can aggregate many email and/or newsgroup sources).

(setq gnus-select-method
      '(nnimap "gmail"
               (nnimap-address "imap.gmail.com")
               (nnimap-server-port 993)
               (nnimap-stream ssl)))

Place a line like the following in ~/.authinfo

machine imap.gmail.com login [email protected] password your-password port 993

and make sure that no-one else can read it with

chmod 600 ~/.authinfo

sending mail

Requirement: gnus uses the starttls tool for encrypted sending of email to the Gmail SMTP server. This is easily installed on modern Debian (including Ubuntu) systems with

apt-get install starttls

The following configures gnus to use the Gmail SMTP server for sending email.

(setq message-send-mail-function 'smtpmail-send-it
      smtpmail-starttls-credentials '(("smtp.gmail.com" 587 nil nil))
      smtpmail-auth-credentials '(("smtp.gmail.com" 587 "[email protected]" nil))
      smtpmail-default-smtp-server "smtp.gmail.com"
      smtpmail-smtp-server "smtp.gmail.com"
      smtpmail-smtp-service 587)

If you don’t want to be prompted for a password on every mail sent, you can add the following line to your ~/.authinfo.

machine smtp.gmail.com login [email protected] your-password secret port 587

Pop

This file can be used to jump start a working Gnus instillation. The following steps will result in a working vanilla Gnus POP instillation.
  1. install the required-packages
  2. follow the gmail specific instructions
  3. tangle this file with `org-babel-tangle’ (with C-c M-b t) creating the starter-kit-gnus-pop.el file which can be loaded by Emacs

(if you run into any problems – the gnus manual is very thorough)

Basic configuration

First off, load up gnus

(require 'gnus)

Tell gnus that your mainly going to be using it for email not as a news reader – after all it’s not longer the late 80s.

(setq gnus-select-method '(nnml ""))

Required packages

A starttls client allows encrypted communication with remote pop3 and IMAP email clients.

openssl implements the Secure Socket Layer (SSL) secure communication protocol.

On Debian systems (including Ubuntu) instillation of starttls and openssl client is as simple as

sudo apt-get install starttls openssl

Gmail Setup

For more information on configuring Gnus with Gmail see GnusGmail on the Emacs Wiki.

For a simple pop3 setup, simply replace your-gmail-email-address and your-gmail-password with your gmail account information in the following tables.

(let ((email (second (first config)))
      (passwd (second (second config))))
  ;; The following adds Gmail as a source of mail for Gnus
  (add-to-list 'mail-sources
               `(pop :server "pop.gmail.com"
                     :port 995
                     :user ,email
                     :password ,passwd
                     :stream ssl))
  ;; The following is used for sending email through gmail using SMTP.
  (setq message-send-mail-function 'smtpmail-send-it
        smtpmail-starttls-credentials '(("smtp.gmail.com" 25 nil nil))
        smtpmail-default-smtp-server "smtp.gmail.com"
        smtpmail-smtp-server "smtp.gmail.com"
        smtpmail-smtp-service 25
        user-mail-address email
        smtpmail-starttls-credentials '(("smtp.gmail.com" 587 nil nil))
        smtpmail-auth-credentials `(("smtp.gmail.com" 587 ,email ,passwd))
        smtpmail-default-smtp-server "smtp.gmail.com"
        smtpmail-smtp-server "smtp.gmail.com"
        smtpmail-smtp-service 587))

Customizations

Once gnus is installed and working, here are some recommended Gnus customizations.

BBDB

BBDBThe Insidious Big Brother Database is Emacs’ contact manager which is very useful for keeping all of your contacts organized for use with gnus.
;;; bbdb
(require 'bbdb)
(require 'bbdb-autoloads)
(setq
 bbdb-file "~/.bbdb"
 bbdb-offer-save 'auto
 bbdb-notice-auto-save-file t
 bbdb-expand-mail-aliases t
 bbdb-canonicalize-redundant-nets-p t
 bbdb-always-add-addresses t
 bbdb-complete-name-allow-cycling t
 )

More attractive Summary View

Thanks to Dan Davison.
;; http://groups.google.com/group/gnu.emacs.gnus/browse_thread/thread/a673a74356e7141f
(when window-system
  (setq gnus-sum-thread-tree-indent "  ")
  (setq gnus-sum-thread-tree-root "") ;; "● ")
  (setq gnus-sum-thread-tree-false-root "") ;; "◯ ")
  (setq gnus-sum-thread-tree-single-indent "") ;; "◎ ")
  (setq gnus-sum-thread-tree-vertical        "")
  (setq gnus-sum-thread-tree-leaf-with-other "├─► ")
  (setq gnus-sum-thread-tree-single-leaf     "╰─► "))
(setq gnus-summary-line-format
      (concat
       "%0{%U%R%z%}"
       "%3{│%}" "%1{%d%}" "%3{│%}" ;; date
       "  "
       "%4{%-20,20f%}"               ;; name
       "  "
       "%3{│%}"
       " "
       "%1{%B%}"
       "%s\n"))
(setq gnus-summary-display-arrow t)