From 092d3725c4ada28fd92dcedeb290ce81bb03d9b0 Mon Sep 17 00:00:00 2001 From: Random936 Date: Wed, 20 Sep 2023 18:45:52 -0700 Subject: [PATCH] Added mu4e to emacs config --- .emacs.d/email.org | 73 +++++++++++++++++++++++++++++++++++++--------- .mbsyncrc | 21 +++++++++++++ 2 files changed, 81 insertions(+), 13 deletions(-) create mode 100644 .mbsyncrc diff --git a/.emacs.d/email.org b/.emacs.d/email.org index 19ad95f..6a20007 100644 --- a/.emacs.d/email.org +++ b/.emacs.d/email.org @@ -1,18 +1,65 @@ #+TITLE: Email Configuration -Setup ~mu4e~ to give emacs the capability to send emails using my gmail account. +* Initial Setup -#+begin_src emacs-lisp -;; (use-package mu4e -;; :ensure nil -;; :config -;; ;; Avoids syncing issues. -;; (setq mu4e-change-filenames-when-moving t) +Before installing any packages with emacs, there is some initial setup that needs to be done. The first part of this is installing isync. Isync is the actual program that is used to sync mail with remote imap servers such as the one used by gmail. -;; ;; Refresh mail every X seconds. Set to 5 minutes currently -;; (setq mu4e-update-interval (* 5 60)) -;; (setq mu4e-get-mail-command "mbsync -a") -;; (setq mu4e-maildir "~/Mail") - -;; (setq mu4e-compose-format-flowed +This can be installed with the following command: +#+begin_src bash +sudo pacman -S isync +#+end_src + +After this is installed, a config file must be created at the location ~~/.mbsyncrc~ to configure isync to connect to some gmail account. I've included this in the git repo, so after installing everything with ~stow .~, it should already be configured properly. However, some information such as the username and password might need to be updated. + +The password uses GPG to decrypt some encrypted password file for added security. To create this file, run the following commands: +#+begin_src bash +vim ~/.passwords/gmail # Add your password to the file. +gpg -c ~/.passwords/gmail # Creates a gmail.gpg file. +rm ~/.passwords/gmail # Remove the plaintext password file. +#+end_src + +** Disclaimer + +If you are using two factor authentication, this will not work. In this case, you will need to create an /app password/. A guide on how to do this can be found [[https://support.google.com/accounts/answer/185833][here]]. From here, I can just replace this value with what used to be my normal password. + +* Mu4e + +In this section, I'm setting up ~mu4e~ to give emacs the capability to send emails using my gmail account. To start, you need to install the ~mu4e~ package outside of emacs. + +#+begin_src bash +yay -S mu +#+end_src + +After installing the ~mu~ client, I also need to run a initial index using the following command: +#+begin_src bash +mbsync -a +mu init --maildir=~/Mail --my-address=randomdude936@gmail.com +mu index +#+end_src + +From here, I can continue onto configuring the ~mu4e~ emacs package. +#+begin_src emacs-lisp +(use-package mu4e + :ensure nil + :load-path "/usr/share/emacs/site-lisp/mu4e/" + :config + ;; Avoids syncing issues. + (setq mu4e-change-filenames-when-moving t) + + ;; Refresh mail every X seconds. Set to 5 minutes currently + (setq mu4e-update-interval (* 5 60)) + (setq mu4e-get-mail-command "mbsync -a") + (setq mu4e-maildir "~/Mail") + + (setq mu4e-drafts-folder "/[Gmail]/Drafts") + (setq mu4e-sent-folder "/[Gmail]/Sent Mail") + (setq mu4e-refile-folder "/[Gmail]/All Mail") + (setq mu4e-trash-folder "/[Gmail]/Trash") + + (setq mu4e-maildir-shortcuts + '((:maildir "/Inbox" :key ?i) + (:maildir "/[Gmail]/Sent Mail" :key ?s) + (:maildir "/[Gmail]/Trash" :key ?t) + (:maildir "/[Gmail]/Drafts" :key ?d) + (:maildir "/[Gmail]/All Mail" :key ?d)))) #+end_src diff --git a/.mbsyncrc b/.mbsyncrc new file mode 100644 index 0000000..8103219 --- /dev/null +++ b/.mbsyncrc @@ -0,0 +1,21 @@ +IMAPAccount gmail +Host imap.gmail.com +User randomdude936@gmail.com +PassCmd "gpg --quiet --for-your-eyes-only --no-tty --decrypt ~/.passwords/gmail.gpg" +SSLType IMAPS +CertificateFile /etc/ssl/certs/ca-certificates.crt + +IMAPStore gmail-remote +Account gmail + +MaildirStore gmail-local +Subfolders Verbatim +Path ~/Mail/ +Inbox ~/Mail/Inbox + +Channel gmail +Far :gmail-remote: +Near :gmail-local: +Patterns * ![Gmail]* "[Gmail]/Sent Mail" "[Gmail]/Starred" "[Gmail]/All Mail" "[Gmail]/Trash" +Create Both +SyncState * \ No newline at end of file