Bala's Blog

Receive/send multiple emails with Gnus

October 8 2017
185 words, ~1 min. read
emacs,  gnus 

I configured gnus for receiving/sending emails from multiple domains; also, I learnt to customize the group buffer, using the following configuration,

  1. Create ~/.gnus
  (require 'smtpmail)

  (setq
   user-full-name "<user name>"

   gnus-select-method '(nnnil)
   gnus-secondary-select-methods
   '((nnimap "outlook"
			 (nnimap-address "imap-mail.outlook.com")
			 (nnimap-server-port 993)
			 (nnimap-stream ssl))
	 (nnimap "yahoo"
			 (nnimap-address "imap.mail.yahoo.com")
			 (nnimap-server-port 993)
			 (nnimap-stream ssl)))

   gnus-parameters
   '(("outlook.*"
	  (display . all)
	  (posting-style
	   (address "<username>@outlook.com")
	   (From "<username>@outlook.com")
	   (X-Message-SMTP-Method "smtp smtp-mail.outlook.com 587 <username>@outlook.com")))
	 ("yahoo.*"
	  (display . all)
	  (posting-style
	   (address "<username>@yahoo.com")
	   (From "<username>@yahoo.com")
	   (X-Message-SMTP-Method "smtp smtp.mail.yahoo.com 587 <username>@yahoo.com"))))

   message-send-mail-function 'smtpmail-send-it
   message-generate-headers-first t
   message-kill-buffer-on-exit t

   ;; ensure sent items are stored remotely and marked as read
   gnus-message-archive-group
   '(("outlook.*" "nnimap+outlook:Sent Items")
	 ("yahoo.*" "nnimap+yahoo:Sent"))
   gnus-gcc-mark-as-read t

   gnus-check-new-newsgroups nil
  )

  ;; use topic mode
  (add-hook 'gnus-group-mode-hook 'gnus-topic-mode)

  ;; topology
  (eval-after-load 'gnus-topic
	'(progn
	   (setq gnus-topic-topology '(("Gnus" visible)
								   (("Mail" visible)
									(("outlook" visible nil nil))
									(("yahoo" visible nil nil)))
								   ))
	   (setq gnus-topic-alist '(("Gnus")
								("outlook" "nnimap+outlook:Inbox")
								("yahoo" "nnimap+yahoo:Inbox")
								))
	   ))

  ;; demon to fetch email every 5 min when idle for 5 min
  (gnus-demon-add-handler 'gnus-demon-scan-news 5 5)
  (gnus-demon-init)
  1. Create ~/.authinfo[.gpg]
machine outlook login <username>@outlook.com password <password>
machine smtp-mail.outlook.com login <username>@outlook.com password <password>

machine yahoo login <username>@yahoo.com password <password>
machine smtp.mail.yahoo.com login <username>@yahoo.com password <password>