Skip to content

Instantly share code, notes, and snippets.

@alexispurslane
Last active June 1, 2024 13:53
Show Gist options
  • Save alexispurslane/28be85797872fcc3fda80e2aa973903c to your computer and use it in GitHub Desktop.
Save alexispurslane/28be85797872fcc3fda80e2aa973903c to your computer and use it in GitHub Desktop.
A complete and fully-working (including STARTTLS encryption and HTML emails) setup to use Proton Mail Bridge with emacs
(defun user/mail-layer ()
"Set GNUS up with asynchronous mail sending, and Proton Mail support,
and a relatively modern layout!
Loads:
- `async': for asynchronous mail"
(use-package async
:demand t
:config
(load "smtpmail-async.el")
(setq message-send-mail-function 'async-smtpmail-send-it)
(setq send-mail-function 'async-smtpmail-send-it))
(with-eval-after-load "gnus"
(require 'imap)
(require 'gnus-registry)
(setq nnmail-expiry-wait 'immediate)
(setq gnus-select-method '(nnimap "localhost"
(nnimap-address "127.0.0.1")
(nnimap-server-port 1143)
(nnimap-stream starttls)))
(setq mail-sources '((imap :server "127.0.0.1"
:user "<your full email address>"
:password "<password from Bridge>")))
(setq gnus-summary-mark-as-read-forward t)
(setq gnus-parameters '((".*" (display . all))))
(setq gnus-inhibit-images nil)
(setq gnus-large-newsgroup nil)
(setq smtpmail-debug-info t)
(setq smtpmail-debug-verb t)
(setq smtpmail-default-smtp-server "127.0.0.1")
(setq smtpmail-smtp-server "127.0.0.1")
(setq smtpmail-stream-type 'starttls)
(setq smtpmail-smtp-service 1025)
(setq smtpmail-smtp-user "<your full email>")
(setq user-mail-address "<your full email>")
(setq smtpmail-servers-requiring-authorization ".*")
(setq user-full-name "<your full email>")
(require 'smtpmail)
;;;; Gnus Window Layout
;;;;; Layout when just viewing the summary view
(gnus-add-configuration
'(summary
(horizontal 1.0
(vertical 25 (group 1.0))
(vertical 1.0
(summary 1.0 point)))))
;;;;; Layout when gnus is showing an individual message
(gnus-add-configuration
'(article
(horizontal 1.0
(vertical 25 (group 1.0))
(vertical 1.0
(summary 0.25 point)
(article 1.0)))))
;;;;; Layout when composing a message
(gnus-add-configuration
'(message
(horizontal 1.0
(vertical 25 (group 1.0))
(vertical 1.0
(summary 0.25 point)
(message 1.0)))))
;;;;; Layout when replying to message
(gnus-add-configuration
'(reply
(horizontal 1.0
(vertical 25 (group 1.0))
(vertical 1.0
(summary 0.25 point)
(article 0.3)
(reply 1.0)))))
(add-hook 'message-mode-hook (lambda ()
(+core--internal-local-map!
"S" #'message-send-and-exit
"H" #'org-mime-htmlize)
(general-nmap
"q" #'message-kill-buffer))))
;;;; Get email notifications on the desktop!
(use-package gnus-desktop-notify
:defer 10
:config
(gnus-desktop-notify-mode)
(gnus-demon-init)
;; Check for new mail once every five minutes if Emacs has
;; been idle for two minutes
(gnus-demon-add-handler 'gnus-demon-scan-mail 5 2)
;; Check mail once a day mid day
(gnus-demon-add-handler 'gnus-demon-scan-mail "12:00" nil)
;; Make sure to time-out gnus
(advice-add 'gnus-demon-scan-mail
:around (lambda (oldfun)
(with-timeout (120 (message "Gnus timed out"))
(funcall oldfun time idle)))))
;;;; Send HTML emails via org-mode
(use-package org-mime
:commands (org-mime-htmlize)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment