This is part of the Emacs Starter Kit.
Configuration for the notoriously difficult to configure Gnus email client
- 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.
- tangle this file Run the
org-babel-tangle
command to extract the code embedded in this file into astarter-git-gnus-imap.el
file which can be added to your configuration, and a~/.authinfo
file which will be used by gnus. - 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). - view your mail After gnus boots up you will see the “Group
Buffer” (see Group-Buffer). Each line is a mail “Group”, hit
SPACE
orENTER
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
- pressing
(setq install-packages (list 'w3m
'gnus-desktop-notify
'bbdb))
(dolist (package install-packages) (package-install package))
machine imap.gmail.com login [email protected] password your-password port 993
machine smtp.gmail.com login [email protected] your-password secret port 587
chmod 600 ~/.authinfo
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 openssl
Where your mail will be saved locally default value will be ~/gmail
.
(require 'gnus)
(setq nnml-directory "~/Templates/Mail")
(setq message-directory "~/Templates/Mail")
(setq gnus-asynchronous t)
(require 'gnus-desktop-notify)
(gnus-desktop-notify-mode)
(gnus-demon-add-scanmail)
;;(setq mm-discouraged-alternatives '("text/html" "text/richtext"))
Set Gmail as the primary source for incoming mail (Gnus can aggregate many email and/or newsgroup sources).
(require 'nnir)
;; @see http://www.emacswiki.org/emacs/GnusGmail#toc1
(setq gnus-select-method '(nntp "news.gmane.org"))
(setq pop3-leave-mail-on-server t)
;; ask encyption password once
(setq epa-file-cache-passphrase-for-symmetric-encryption t)
(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-expunge-on-close always)
(gnus-check-new-newsgroups nil)
; @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]/Bin")
(nnmail-expiry-wait 90)))
;; (add-to-list 'gnus-secondary-select-methods
;; '(nnimap "outlook"
;; (nnimap-address "outlook.com")
;; (nnimap-server-port 1143)
;; (nnimap-stream ssl)
;; (nnir-search-engine imap)
;; (nnimap-expunge-on-close newer)
;; (gnus-check-new-newsgroups nil)
;; (nnmail-expiry-wait 90)))
(setq gnus-thread-sort-functions
'((not gnus-thread-sort-by-date)
(not gnus-thread-sort-by-number)))
(setq gnus-use-cache t)
;; BBDB: Address list
(add-to-list 'load-path "~/.emacs.d/bbdb/")
(require 'bbdb)
(bbdb-initialize 'message 'gnus 'sendmail)
(add-hook 'gnus-startup-hook 'bbdb-insinuate-gnus)
(setq bbdb/mail-auto-create-p t
bbdb/news-auto-create-p t)
;; auto-complete emacs address using bbdb UI
(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's .gnus
(setq gnus-read-active-file 'some)
(add-hook 'gnus-group-mode-hook 'gnus-topic-mode)
(eval-after-load 'mailcap
'(progn
(cond
;; on OSX, maybe change mailcap-mime-data?
((eq system-type 'darwin))
;; on Windows, maybe change mailcap-mime-data?
((eq system-type 'windows-nt))
(t (mailcap-parse-mailcaps)))));; 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
;; messa '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)
;; Read HTML mail
;; You need install the command line brower 'w3m' and Emacs plugin 'w3m'
(setq mm-text-html-renderer 'w3m)
;; Setup to send email through SMTP
(setq message-send-mail-function 'smtpmail-send-it
smtpmail-default-smtp-server "smtp.gmail.com"
smtpmail-smtp-service 587
smtpmail-local-domain "homepc")
(setq gnus-use-correct-string-widths nil)
(eval-after-load 'gnus-topic
'(progn
(setq gnus-message-archive-group '((format-time-string "sent.%Y")))
(setq gnus-server-alist '(("archive" nnfolder "archive" (nnfolder-directory "~/Templates/Mail/archive")
(nnfolder-active-file "~/Templates/Mail/archive/active")
(nnfolder-get-new-mail nil)
(nnfolder-inhibit-expiry t))))
(setq gnus-topic-topology '(("Gnus" visible)
(("misc" visible))
(("hotmail" visible nil nil))
(("gmail" visible nil nil))))
(setq gnus-topic-alist '(("gmail" ; the key of topic
"INBOX"
"[Gmail]/Sent Mail"
"[Gmail]/Bin"
"Sent Mail"
"Drafts")
("outlook" ; the key of topic
"nnimap+outlook:Inbox"
"nnimap+outlook:Drafts"
"nnimap+outlook:Sent"
"nnimap+outlook:Junk"
"nnimap+outlook:Deleted")
("misc" ; the key of topic
"nnfolder+archive:sent.2015-12"
"nnfolder+archive:sent.2016"
"nnfolder+archive:sent.2017"
"nndraft:drafts")
("Gnus")))))
(message "------ Starter Kit Gnus loaded ------")