Bits and Bytes

Notes from the deviant pursuits of a technical vagrant

Setting up Gnus in Spacemacs

Create the .authinfo.gpg file

Note: you may have to create a gpg key first[1]: gpg --gen-key

Create an application password for gmail as described here[2].

In Spacemacs, open a scratch buffer, and insert the following[3]:

machine smtp.gmail.com login name@gmail.com password SUPER_SECRET_PASS
machine imap.gmail.com login name@gmail.com port 993 password SUPER_SECRET_PASS

Substitute "name@gmail.com" for your gmail, and "SUPER_SECRET_PASS" for your application password.

Save the file:

  • Ensure that the gpg key that you created earlier is selected in the buffer that automatically opens
  • Move the cursor over "[Ok]" in that buffer, and press C-c, C-c
  • Enter the password for the key when prompted

Configure Gnus in the .spacemacs File

Copy the following into the dotspacemacs/init function in the .spacemacs file:

;; Get email, and store in nnml
(setq gnus-secondary-select-methods
'(
  (nnimap "gmail"
           (nnimap-address
            "imap.gmail.com")
           (nnimap-server-port 993)
           (nnimap-stream ssl))
  ))

;; Send email via Gmail:
(setq message-send-mail-function 'smtpmail-send-it
  smtpmail-default-smtp-server "smtp.gmail.com")

;; Archive outgoing email in Sent folder on imap.gmail.com:
(setq gnus-message-archive-method '(nnimap "imap.gmail.com")
    gnus-message-archive-group "[Gmail]/Sent Mail")

;; set return email address based on incoming email address
(setq gnus-posting-styles
    '(((header "to" "address@outlook.com")
       (address "address@outlook.com"))
  ((header "to" "address@gmail.com")
     (address "address@gmail.com"))))

;; store email in ~/gmail directory
(setq nnml-directory "~/gmail")
(setq message-directory "~/gmail")

Restart Spacemacs and use SPC a g to launch gnus.

Setting the Proper SMTP Service Port

In order to send emails, you need to set the proper port number which is used when interacting with the SMTP server[4]; add the following to the dotspacemacs/init function in the .spacemacs file[5]:

(setq smtpmail-smtp-service 587)

Comments

comments powered by Disqus