summaryrefslogtreecommitdiff
path: root/.emacs.d/snippets/email-module.el
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2023-01-26 17:14:47 +0200
committerThanos Apollo <[email protected]>2023-01-26 17:14:47 +0200
commitec080ddb66f73ec2ce5b1ff99a794f72aa14c427 (patch)
treee15ef20aa17ebe249c0f9bacea13f662e5b65ee6 /.emacs.d/snippets/email-module.el
parentbb54f635adda5c0ef7f86a5bcc1b2a1c8fd2bfbf (diff)
emacs: Add email-module
Diffstat (limited to '.emacs.d/snippets/email-module.el')
-rw-r--r--.emacs.d/snippets/email-module.el64
1 files changed, 64 insertions, 0 deletions
diff --git a/.emacs.d/snippets/email-module.el b/.emacs.d/snippets/email-module.el
new file mode 100644
index 0000000..bb5559f
--- /dev/null
+++ b/.emacs.d/snippets/email-module.el
@@ -0,0 +1,64 @@
+(require 'mu4e)
+
+(setq mu4e-update-interval (* 10 60))
+(setq mu4e-get-mail-command "mbsync -a")
+(setq mu4e-maildir-list "~/Mail/Inbox")
+;; assumed Maildir layout
+ ;; ~/Maildir/Account0/{Inbox,Sent,Trash}
+ ;; ~/Maildir/Account1/{Inbox,Sent,Trash}
+ ;; where Account0 is context name
+ (defun my-make-mu4e-context (context-name full-name mail-address signature server)
+ "Return a mu4e context named CONTEXT-NAME with :match-func matching
+ folder name CONTEXT-NAME in Maildir. The context's `user-mail-address',
+ `user-full-name' and `mu4e-compose-signature' is set to MAIL-ADDRESS
+ FULL-NAME and SIGNATURE respectively.
+ Special folders are set to context specific folders."
+ (let ((dir-name (concat "/" context-name)))
+ (make-mu4e-context
+ :name context-name
+ ;; we match based on the maildir of the message
+ ;; this matches maildir /Arkham and its sub-directories
+ :match-func
+ `(lambda (msg)
+ (when msg
+ (string-match-p
+ ,(concat "^" dir-name)
+ (mu4e-message-field msg :maildir))))
+ :vars
+ `((user-mail-address . ,mail-address)
+ (user-full-name . ,full-name)
+ (mu4e-sent-folder . ,(concat dir-name "/Sent"))
+ (mu4e-drafts-folder . ,(concat dir-name "/Drafts"))
+ (mu4e-trash-folder . ,(concat dir-name "/Trash"))
+ (mu4e-trash-folder . ,(concat dir-name "/Starred"))
+ (mu4e-refile-folder . ,(concat dir-name "/Archive"))
+ (smtpmail-smtp-server . , server)
+ (mu4e-compose-signature . ,signature)))))
+ ;;Fixing duplicate UID errors when using mbsync and mu4e
+(setq mu4e-change-filenames-when-moving t)
+
+(setq mu4e-maildir-shortcuts
+ '(("/Gmail/Inbox" . ?i)
+ ("/Fastmail/Inbox" . ?s)
+ ;; ("/Gmail/Trash" . ?t)
+ ;; ("/Gmail/Drafts" . ?d)
+ ;; ("/Gmail/[Gmail]/All Mail" . ?a
+ ))
+
+(setq mu4e-contexts
+ `(,(my-make-mu4e-context
+ "Gmail" "Thanos Apollo"
+ "[email protected]" "Thanos\n https://thanosapollo.co"
+ "smtp.gmail.com")
+ ,(my-make-mu4e-context
+ "Fastmail" "Thanos Apollo"
+ "[email protected]" "Thanos"
+ "smtp.fastmail.com")))
+
+(setq smtpmail-smtp-service 465
+ smtpmail-stream-type 'ssl
+ smtpmail-smtp-server "smtp.fastmail.com")
+
+
+
+(setq message-send-mail-function 'smtpmail-send-it)