Email IMAP working - Will test SMTP

This commit is contained in:
Eduardo Cueto-Mendoza 2024-04-12 17:51:31 +01:00
parent 09e4066ab8
commit 4a8a18ce39
2 changed files with 68 additions and 312 deletions

176
Emacs.org
View File

@ -981,52 +981,6 @@ This will install the [[https://github.com/theia-ide/typescript-language-server]
#+begin_src emacs-lisp
;;(require 'flymake)
;;(defun flymake-get-tex-args (file-name)
;;(list "pdflatex"
;;(list "-file-line-error" "-draftmode" "-interaction=nonstopmode" file-name)))
;;(add-hook 'LaTeX-mode-hook 'flymake-mode)
;;(defun turn-on-outline-minor-mode ()
;;(outline-minor-mode 1))
;;(add-hook 'LaTeX-mode-hook 'turn-on-outline-minor-mode)
;;(add-hook 'latex-mode-hook 'turn-on-outline-minor-mode)
;;(setq outline-minor-mode-prefix "\C-c \C-o") ; Or something else
;;(require 'tex-site)
;;(autoload 'reftex-mode "reftex" "RefTeX Minor Mode" t)
;;(autoload 'turn-on-reftex "reftex" "RefTeX Minor Mode" nil)
;;(autoload 'reftex-citation "reftex-cite" "Make citation" nil)
;;(autoload 'reftex-index-phrase-mode "reftex-index" "Phrase Mode" t)
;;(add-hook 'latex-mode-hook 'turn-on-reftex) ; with Emacs latex mode
;; (add-hook 'reftex-load-hook 'imenu-add-menubar-index)
;;(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
;;(setq LaTeX-eqnarray-label "eq"
;;LaTeX-equation-label "eq"
;;LaTeX-figure-label "fig"
;;LaTeX-table-label "tab"
;;LaTeX-myChapter-label "chap"
;;TeX-auto-save t
;;TeX-newline-function 'reindent-then-newline-and-indent
;;TeX-parse-self t
;;TeX-style-path
;;'("style/" "auto/"
;;"/usr/share/emacs21/site-lisp/auctex/style/"
;;"/var/lib/auctex/emacs21/"
;;"/usr/local/share/emacs/site-lisp/auctex/style/")
;;LaTeX-section-hook
;;'(LaTeX-section-heading
;;LaTeX-section-title
;;LaTeX-section-toc
;;LaTeX-section-section
;;LaTeX-section-label))
;; Better configuration but rquires pdf-tools
(use-package pdf-tools
@ -1054,9 +1008,9 @@ This will install the [[https://github.com/theia-ide/typescript-language-server]
:config
(setq reftex-cite-prompt-optional-args t)) ;; Prompt for empty optional arguments in cite
(use-package auto-dictionary
:ensure t
:init(add-hook 'flyspell-mode-hook (lambda () (auto-dictionary-mode 1))))
;(use-package auto-dictionary
; :ensure t
; :init(add-hook 'flyspell-mode-hook (lambda () (auto-dictionary-mode 1))))
(use-package company-auctex
:ensure t
@ -1507,6 +1461,11 @@ Dired is a built-in file manager for Emacs that does some pretty amazing things!
:defer 20 ; Wait until 20 seconds after startup
;:defer t
:config
;; Make sure that moving a message (like to Trash) causes the
;; message to get a new file name. This helps to avoid the
;; dreaded "UID is N beyond highest assigned" error.
;; See this link for more info: https://stackoverflow.com/a/43461973
(setq mu4e-change-filenames-when-moving t)
;; Load org-mode integration
;(require 'org-mu4e)
@ -1516,112 +1475,31 @@ Dired is a built-in file manager for Emacs that does some pretty amazing things!
(setq mu4e-get-mail-command "mbsync -a")
(setq mu4e-maildir "~/Mail")
;; Use Ivy for mu4e completions (maildir folders, etc)
(setq mu4e-completing-read-function #'ivy-completing-read)
(setq mu4e-drafts-folder "/Drafts")
(setq mu4e-sent-folder "/Sent")
(setq mu4e-refile-folder "/Inbox")
(setq mu4e-trash-folder "/Trash")
;; Make sure that moving a message (like to Trash) causes the
;; message to get a new file name. This helps to avoid the
;; dreaded "UID is N beyond highest assigned" error.
;; See this link for more info: https://stackoverflow.com/a/43461973
(setq mu4e-change-filenames-when-moving t)
;; Set up contexts for email accounts
(setq mu4e-contexts
`(,(make-mu4e-context
:name "Fastmail"
:match-func (lambda (msg) (when msg
(string-prefix-p "/Fastmail" (mu4e-message-field msg :maildir))))
:vars '(
(user-full-name . "David Wilson")
(user-mail-address . "david@daviwil.com")
(mu4e-sent-folder . "/Fastmail/Sent Items")
(mu4e-trash-folder . "/Fastmail/Trash")
(mu4e-drafts-folder . "/Fastmail/Drafts")
(mu4e-refile-folder . "/Fastmail/Archive")
(mu4e-sent-messages-behavior . sent)))
,(make-mu4e-context
:name "Personal"
:match-func (lambda (msg) (when msg
(string-prefix-p "/Personal" (mu4e-message-field msg :maildir))))
:vars '(
(mu4e-sent-folder . "/Personal/Sent")
(mu4e-trash-folder . "/Personal/Deleted")
(mu4e-refile-folder . "/Personal/Archive")))))
(setq mu4e-context-policy 'pick-first)
;; Prevent mu4e from permanently deleting trashed items
;; This snippet was taken from the following article:
;; http://cachestocaches.com/2017/3/complete-guide-email-emacs-using-mu-and-/
(defun remove-nth-element (nth list)
(if (zerop nth) (cdr list)
(let ((last (nthcdr (1- nth) list)))
(setcdr last (cddr last))
list)))
(setq mu4e-marks (remove-nth-element 5 mu4e-marks))
(add-to-list 'mu4e-marks
'(trash
:char ("d" . "▼")
:prompt "dtrash"
:dyn-target (lambda (target msg) (mu4e-get-trash-folder msg))
:action (lambda (docid msg target)
(mu4e~proc-move docid
(mu4e~mark-check-target target) "-N"))))
;; Display options
(setq mu4e-view-show-images t)
(setq mu4e-view-show-addresses 't)
;; Composing mail
(setq mu4e-compose-dont-reply-to-self t)
;; Use mu4e for sending e-mail
(setq mail-user-agent 'mu4e-user-agent
message-send-mail-function 'smtpmail-send-it
smtpmail-smtp-server "smtp.fastmail.com"
smtpmail-smtp-service 465
smtpmail-stream-type 'ssl)
;; Signing messages (use mml-secure-sign-pgpmime)
(setq mml-secure-openpgp-signers '("3A74994A3EB078555A0FFDD599F6A2219E3A3C44"))
;; (See the documentation for `mu4e-sent-messages-behavior' if you have
;; additional non-Gmail addresses and want assign them different
;; behavior.)
;; setup some handy shortcuts
;; you can quickly switch to your Inbox -- press ``ji''
;; then, when you want archive some messages, move them to
;; the 'All Mail' folder by pressing ``ma''.
(setq mu4e-maildir-shortcuts
'(("/Fastmail/INBOX" . ?i)
("/Fastmail/Lists/*" . ?l)
("/Fastmail/Sent Mail" . ?s)
("/Fastmail/Trash" . ?t)))
'(("/Inbox" . ?i)
("/Sent" . ?s)
("/Trash" . ?t)
("/Drafts" . ?d)
("/Spam" . ?z)
("/Archive" . ?a)
))
(add-to-list 'mu4e-bookmarks
'(:name "All Inboxes"
:query "maildir:/Fastmail/INBOX OR maildir:/Personal/Inbox"
:key ?i))
;; don't keep message buffers around
(setq message-kill-buffer-on-exit t)
(setq dw/mu4e-inbox-query
"(maildir:/Personal/Inbox OR maildir:/Fastmail/INBOX) AND flag:unread")
(defun dw/go-to-inbox ()
(interactive)
(mu4e-headers-search dw/mu4e-inbox-query))
(dw/leader-key-def
"m" '(:ignore t :which-key "mail")
"mm" 'mu4e
"mc" 'mu4e-compose-new
"mi" 'dw/go-to-inbox
"ms" 'mu4e-update-mail-and-index)
;(dw/leader-key-def
; "m" '(:ignore t :which-key "mail")
; "mm" 'mu4e
; "mc" 'mu4e-compose-new
; "mi" 'dw/go-to-inbox
; "ms" 'mu4e-update-mail-and-index)
;; Start mu4e in the background so that it syncs mail periodically
(mu4e t))
(mu4e t)
)
#+end_src

176
init.el
View File

@ -619,52 +619,6 @@
:ensure t
:hook (julia-mode . julia-snail-mode))
;;(require 'flymake)
;;(defun flymake-get-tex-args (file-name)
;;(list "pdflatex"
;;(list "-file-line-error" "-draftmode" "-interaction=nonstopmode" file-name)))
;;(add-hook 'LaTeX-mode-hook 'flymake-mode)
;;(defun turn-on-outline-minor-mode ()
;;(outline-minor-mode 1))
;;(add-hook 'LaTeX-mode-hook 'turn-on-outline-minor-mode)
;;(add-hook 'latex-mode-hook 'turn-on-outline-minor-mode)
;;(setq outline-minor-mode-prefix "\C-c \C-o") ; Or something else
;;(require 'tex-site)
;;(autoload 'reftex-mode "reftex" "RefTeX Minor Mode" t)
;;(autoload 'turn-on-reftex "reftex" "RefTeX Minor Mode" nil)
;;(autoload 'reftex-citation "reftex-cite" "Make citation" nil)
;;(autoload 'reftex-index-phrase-mode "reftex-index" "Phrase Mode" t)
;;(add-hook 'latex-mode-hook 'turn-on-reftex) ; with Emacs latex mode
;; (add-hook 'reftex-load-hook 'imenu-add-menubar-index)
;;(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
;;(setq LaTeX-eqnarray-label "eq"
;;LaTeX-equation-label "eq"
;;LaTeX-figure-label "fig"
;;LaTeX-table-label "tab"
;;LaTeX-myChapter-label "chap"
;;TeX-auto-save t
;;TeX-newline-function 'reindent-then-newline-and-indent
;;TeX-parse-self t
;;TeX-style-path
;;'("style/" "auto/"
;;"/usr/share/emacs21/site-lisp/auctex/style/"
;;"/var/lib/auctex/emacs21/"
;;"/usr/local/share/emacs/site-lisp/auctex/style/")
;;LaTeX-section-hook
;;'(LaTeX-section-heading
;;LaTeX-section-title
;;LaTeX-section-toc
;;LaTeX-section-section
;;LaTeX-section-label))
;; Better configuration but rquires pdf-tools
(use-package pdf-tools
@ -692,9 +646,9 @@
:config
(setq reftex-cite-prompt-optional-args t)) ;; Prompt for empty optional arguments in cite
(use-package auto-dictionary
:ensure t
:init(add-hook 'flyspell-mode-hook (lambda () (auto-dictionary-mode 1))))
;(use-package auto-dictionary
; :ensure t
; :init(add-hook 'flyspell-mode-hook (lambda () (auto-dictionary-mode 1))))
(use-package company-auctex
:ensure t
@ -901,6 +855,11 @@
:defer 20 ; Wait until 20 seconds after startup
;:defer t
:config
;; Make sure that moving a message (like to Trash) causes the
;; message to get a new file name. This helps to avoid the
;; dreaded "UID is N beyond highest assigned" error.
;; See this link for more info: https://stackoverflow.com/a/43461973
(setq mu4e-change-filenames-when-moving t)
;; Load org-mode integration
;(require 'org-mu4e)
@ -910,112 +869,31 @@
(setq mu4e-get-mail-command "mbsync -a")
(setq mu4e-maildir "~/Mail")
;; Use Ivy for mu4e completions (maildir folders, etc)
(setq mu4e-completing-read-function #'ivy-completing-read)
(setq mu4e-drafts-folder "/Drafts")
(setq mu4e-sent-folder "/Sent")
(setq mu4e-refile-folder "/Inbox")
(setq mu4e-trash-folder "/Trash")
;; Make sure that moving a message (like to Trash) causes the
;; message to get a new file name. This helps to avoid the
;; dreaded "UID is N beyond highest assigned" error.
;; See this link for more info: https://stackoverflow.com/a/43461973
(setq mu4e-change-filenames-when-moving t)
;; Set up contexts for email accounts
(setq mu4e-contexts
`(,(make-mu4e-context
:name "Fastmail"
:match-func (lambda (msg) (when msg
(string-prefix-p "/Fastmail" (mu4e-message-field msg :maildir))))
:vars '(
(user-full-name . "David Wilson")
(user-mail-address . "david@daviwil.com")
(mu4e-sent-folder . "/Fastmail/Sent Items")
(mu4e-trash-folder . "/Fastmail/Trash")
(mu4e-drafts-folder . "/Fastmail/Drafts")
(mu4e-refile-folder . "/Fastmail/Archive")
(mu4e-sent-messages-behavior . sent)))
,(make-mu4e-context
:name "Personal"
:match-func (lambda (msg) (when msg
(string-prefix-p "/Personal" (mu4e-message-field msg :maildir))))
:vars '(
(mu4e-sent-folder . "/Personal/Sent")
(mu4e-trash-folder . "/Personal/Deleted")
(mu4e-refile-folder . "/Personal/Archive")))))
(setq mu4e-context-policy 'pick-first)
;; Prevent mu4e from permanently deleting trashed items
;; This snippet was taken from the following article:
;; http://cachestocaches.com/2017/3/complete-guide-email-emacs-using-mu-and-/
(defun remove-nth-element (nth list)
(if (zerop nth) (cdr list)
(let ((last (nthcdr (1- nth) list)))
(setcdr last (cddr last))
list)))
(setq mu4e-marks (remove-nth-element 5 mu4e-marks))
(add-to-list 'mu4e-marks
'(trash
:char ("d" . "")
:prompt "dtrash"
:dyn-target (lambda (target msg) (mu4e-get-trash-folder msg))
:action (lambda (docid msg target)
(mu4e~proc-move docid
(mu4e~mark-check-target target) "-N"))))
;; Display options
(setq mu4e-view-show-images t)
(setq mu4e-view-show-addresses 't)
;; Composing mail
(setq mu4e-compose-dont-reply-to-self t)
;; Use mu4e for sending e-mail
(setq mail-user-agent 'mu4e-user-agent
message-send-mail-function 'smtpmail-send-it
smtpmail-smtp-server "smtp.fastmail.com"
smtpmail-smtp-service 465
smtpmail-stream-type 'ssl)
;; Signing messages (use mml-secure-sign-pgpmime)
(setq mml-secure-openpgp-signers '("3A74994A3EB078555A0FFDD599F6A2219E3A3C44"))
;; (See the documentation for `mu4e-sent-messages-behavior' if you have
;; additional non-Gmail addresses and want assign them different
;; behavior.)
;; setup some handy shortcuts
;; you can quickly switch to your Inbox -- press ``ji''
;; then, when you want archive some messages, move them to
;; the 'All Mail' folder by pressing ``ma''.
(setq mu4e-maildir-shortcuts
'(("/Fastmail/INBOX" . ?i)
("/Fastmail/Lists/*" . ?l)
("/Fastmail/Sent Mail" . ?s)
("/Fastmail/Trash" . ?t)))
'(("/Inbox" . ?i)
("/Sent" . ?s)
("/Trash" . ?t)
("/Drafts" . ?d)
("/Spam" . ?z)
("/Archive" . ?a)
))
(add-to-list 'mu4e-bookmarks
'(:name "All Inboxes"
:query "maildir:/Fastmail/INBOX OR maildir:/Personal/Inbox"
:key ?i))
;; don't keep message buffers around
(setq message-kill-buffer-on-exit t)
(setq dw/mu4e-inbox-query
"(maildir:/Personal/Inbox OR maildir:/Fastmail/INBOX) AND flag:unread")
(defun dw/go-to-inbox ()
(interactive)
(mu4e-headers-search dw/mu4e-inbox-query))
(dw/leader-key-def
"m" '(:ignore t :which-key "mail")
"mm" 'mu4e
"mc" 'mu4e-compose-new
"mi" 'dw/go-to-inbox
"ms" 'mu4e-update-mail-and-index)
;(dw/leader-key-def
; "m" '(:ignore t :which-key "mail")
; "mm" 'mu4e
; "mc" 'mu4e-compose-new
; "mi" 'dw/go-to-inbox
; "ms" 'mu4e-update-mail-and-index)
;; Start mu4e in the background so that it syncs mail periodically
(mu4e t))
(mu4e t)
)
;; Make gc pauses faster by decreasing the threshold.
(setq gc-cons-threshold (* 2 1000 1000))