GNUS and IMAP and SSH

From BNL Physics Computing

Setting up GNUS to access IMAP through SSH. This assumes your machine is setup as "laptop" in this topic.

The .gnus file

The easiest way to describe what to do is just give an example .gnus file.

;;;; Generic setup

;; (optional) This gets rid of the "nnimap:bnl+" lines that clutter
;; the front of each group.
(setq gnus-group-line-format "%M%S%p%P%5y:%B%(%G%)%l %O\n")

;; Make your local system mail default.  This could be removed or
;; added to the gnus-secondary-select-methods
(setq gnus-select-method '(nnml "private"))
(setq nnml-directory "~/nnml")

;; Sending mail through our tunnel to bnl.gov.
;; You might also elect to send through some other provider.
(setq smtpmail-smtp-server "localhost"
      smtpmail-smtp-service 2525	;SSH Tunnel to bnl.gov
      send-mail-function 'smtpmail-send-it
      message-send-mail-function 'smtpmail-send-it)

;; The rest is for IMAP
(setq gnus-secondary-select-methods
      '(
	 (nnimap "bnl"
		 (nnimap-address "localhost")  ; using local tunnel
		 (nnimap-server-port 10993)    ; on this port
		 (nnimap-authenticator login)
		 (nnimap-stream ssl))
	 )

      ; optional, but why not if you are using GNUS!
      ; rules for splitting are below
      nnimap-split-inbox '("INBOX"))
 
(setq nnimap-split-crosspost nil)	;don't cross post splits
(setq nnimap-split-rule
     '(
	("duplicates" "^Gnus-Warning:.*duplicate")
	("myexperiment.software.offline"
	 "^\\(To:\\|Cc:\\).*offline-software@.*myexperiement.bnl.gov.*")
	("ordo" "^From:.*\\(ordo@\\|@ordo.bnl.gov\\)")
	("lists.bnl.gaudi-talk" "^\\(To:\\|From:\\|Cc:\\).*gaudi-talk@lists.bnl.gov")
	("lists.bnl.computer-liaisons" "^\\(From:\\|To:\\|Cc:\\).*computer-liaisons@phyppro1.phy.bnl.gov")
	("lists.bnl.nessus"    "^From:.*noreply@secops.itd.bnl.gov")
	("lists.bnl.linux" "^\\(To:\\|From:\\|Cc:\\).*[< ].*linux.*@lists.bnl.gov")
	("lists.bnl.broadcast" "^To:.*broadcast-l@lists.bnl.gov")
	("lists.bnl.seminars" "^\\(From:\\|To:\\|Cc:\\).*physics-seminars-l@lists.bnl.gov")
	("lists.bnl.physics" "^\\(From:\\|To:\\|Cc:\\).*allphysics@.*bnl.gov")
	("lists.bnl.ags" "^\\(From:\\|To:\\|Cc:\\).*ags.*@.*bnl.gov")
	("lists.bnl.notify" "^\\(From:\\|To:\\|Cc:\\).*[Nn]otify-l.*@.*bnl.gov")
	("lists.bnl.notify" "^\\(From:\\|To:\\|Cc:\\).*bnl-rhel-l.*@.*bnl.gov")
	("lists.bnl.users" "^To:.*users-l@lists.bnl.gov")
	("lists.bnl.users" "^To:.*[uU]serscenter_rhic_news_distribution-l@lists.bnl.gov")
	("lists.bnl.social" "^\\(From:\\|To:\\|Cc:\\).*social-l@lists.bnl.gov")
	("lists.bnl.social" "^\\(From:\\|To:\\|Cc:\\).*asap-l@lists.bnl.gov")
	("lists.bnl.social" "^\\(From:\\|To:\\|Cc:\\).*bnl-scc-l@lists.bnl.gov")
	("lists.bnl.cyberinfo" "^\\(From:\\|To:\\|Cc:\\).*CyberSecurityPOCsa@bnl.gov")
	("lists.bnl.cyberinfo" "^From:.*cyberinfo@bnl.gov")
	("lists.bnl.sysadmin" "^\\(From:\\|To:\\|Cc:\\).*[Ss]ys[Aa]dmin.*@lists.bnl.gov")
	("lists.xxx" "^From:.*no-reply@arXiv.org")
	("root.monitor" "^From:.*monitor@.*bnl.gov")
	("root.monitor" "^From:.*nagios@.*bnl.gov")
	("auto.backup" "^From:.*legatounixmst.itd.bnl.gov.*")
	("auto.cfengine" "^From:.*cfengine@.*bnl.gov")
	("auto.backup" "^Subject:.*BACKUP STATUS.*")
	("auto.logwatch" "^Subject:.*LogWatch.*")
	("auto.cron" "^From: [Cc]ron .*")
	("auto.cron" "^From: .*[Cc]ron Daemon.*")
	("auto.batch" "^Subject: PBS JOB .*")
	("root.nessus" "^Subject: Nessus Scan of ")
	;; One doesn't need this but it is a way to get things out of
	;; the INBOX so /var/mail doesn't fill up.
	("default" "^To:.*\\(USERNAME\\)@bnl.gov")
	("default" "")
))

Switching from nnml

If you previously used nnml backend you may want to move away .newsrc and .newsrc.eld and resubscribe to the newly available groups. Type "^" to access all available groups (IMAP folders).

You can convert your existing nnml folders into mbox with:

cat nnml/mail/folder/* | formail -ds > Mail/mail.folder