Switched mu4e to proton mail instead of gmail

This commit is contained in:
Random936 2024-12-30 12:47:05 -08:00
parent 1e97c512b1
commit 2765632fdc
4 changed files with 51 additions and 61 deletions

View File

@ -16,6 +16,7 @@
brews = [ brews = [
"wireguard-tools" "wireguard-tools"
"bitwarden-cli" "bitwarden-cli"
"pinentry-mac"
"sketchybar" "sketchybar"
"coreutils" "coreutils"
"watch" "watch"
@ -29,6 +30,7 @@
"aerospace" "aerospace"
"bitwarden" "bitwarden"
"tailscale" "tailscale"
"wireshark"
"firefox" "firefox"
"ghostty" "ghostty"
"discord" "discord"

View File

@ -2,35 +2,11 @@
* Initial Setup * Initial Setup
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. Before installing any packages with emacs, there is some initial setup that needs to be done.
This can be installed with the following command: ** Exporting TLS Certificates
#+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. After installing the ~proton-mail-bridge~, you will need to export the certificates by going to Settings > Advanced settings > Export TLS certificates. From here you should place this at the path ~~/.config/protonmail/bridge/~.
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.
** Installation for MacOS
MacOS doesn't include a certificate file in the typical ~/etc/ssl/certs~ directory. Due to this, you have to create a file using the ~Keychain Access~ app.
#+begin_src bash
Open the Application Keychain Access.app
Select System Roots in the sidebar
Select all items listen here ⌘ + a
Export the items with ⇧ + ⌘ + e to the file ~/.mail/certificates/root-certificates.pem
#+end_src
** Mu4e Installation ** Mu4e Installation
@ -44,7 +20,7 @@ yay -S mu
After installing the ~mu~ client, I also need to run a initial index using the following command: After installing the ~mu~ client, I also need to run a initial index using the following command:
#+begin_src bash #+begin_src bash
mbsync -a mkdir ~/.mail && mbsync -a
mu init --maildir=~/.mail --my-address=jadenprovost@gmail.com mu init --maildir=~/.mail --my-address=jadenprovost@gmail.com
mu index mu index
#+end_src #+end_src
@ -123,25 +99,27 @@ This section contains the ~mu4e~ emacs specific configuration.
(:name "Flagged messages" :query "flag:flagged" :key ?f))) (:name "Flagged messages" :query "flag:flagged" :key ?f)))
(setq mu4e-maildir-shortcuts (setq mu4e-maildir-shortcuts
'((:maildir "/Inbox" :key ?i) ;; Proton folders
'((:maildir "INBOX" :key ?i)
(:maildir "/Archive" :key ?a) (:maildir "/Archive" :key ?a)
(:maildir "/Drafts" :key ?d) (:maildir "/Drafts" :key ?d)
(:maildir "/Sent" :key ?s) (:maildir "/Sent" :key ?s)
(:maildir "/Spam" :key ?S)
(:maildir "/Trash" :key ?t) (:maildir "/Trash" :key ?t)
(:maildir "/Finance" :key ?f)
(:maildir "/Packages" :key ?p) ;; My folders
(:maildir "/Work" :key ?w) (:maildir "/Folders/Finance" :key ?f)
(:maildir "/Club" :key ?c) (:maildir "/Folders/Packages" :key ?p)
(:maildir "/UCSC" :key ?u) (:maildir "/Folders/Work" :key ?w)
(:maildir "/Newsletters" :key ?n) (:maildir "/Folders/Club" :key ?c)
(:maildir "/Automated" :key ?A) (:maildir "/Folders/UCSC" :key ?u)
(:maildir "/Spam" :key ?S)))) (:maildir "/Folders/Newsletters" :key ?n))))
#+end_src #+end_src
Adding some configuration to correct ~mu4e~'s default values. Adding some configuration to correct ~mu4e~'s default values.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(setq user-full-name "Jaden Provost Maxwell-Comfort") (setq user-full-name "Jaden Provost Maxwell-Comfort")
(setq user-mail-address "jadenprovost@gmail.com") (setq user-mail-address "jadenprovost@proton.me")
#+end_src #+end_src
* SMTP * SMTP
@ -152,16 +130,22 @@ In order to send mail with ~mu4e~, you must also configure an SMTP client. Base
(use-package smtpmail (use-package smtpmail
:after mu4e :after mu4e
:config :config
(setq smtpmail-stream-type 'ssl (setq smtpmail-stream-type 'starttls
smtpmail-smtp-server "smtp.gmail.com" smtpmail-smtp-server "127.0.0.1"
smtpmail-smtp-service 465)) smtpmail-smtp-service 1025))
(setq send-mail-function 'smtpmail-send-it) (setq send-mail-function 'smtpmail-send-it)
#+end_src #+end_src
When running this however, you need to authenticate by creating an ~~/.authinfo~ file. This file is formatted as follows: When running this however, you need to authenticate by creating an ~~/.authinfo~ file. This file is formatted as follows:
#+begin_src text #+begin_src authinfo
# For gmail
machine smtp.gmail.com port 465 login "<USER>" password "<PASS>" machine smtp.gmail.com port 465 login "<USER>" password "<PASS>"
# For Proton Mail
# Copy the remaining information from the proton-mail-bridge for both IMAP and SMTP
machine 127.0.0.1 port <PORT> login "<USER>" password "<PASS>"
machine 127.0.0.1 port <PORT> login "<USER>" password "<PASS>"
#+end_src #+end_src
Similarly to the password configured above for the IMAP server, you can also pass an ~authinfo.gpg~ file for some added security. Similarly to the password configured above for the IMAP server, you can also pass an ~authinfo.gpg~ file for some added security. If you are using proton mail, make sure this matches the path set in your ~.mbsyncrc~ file.

View File

@ -1,25 +1,25 @@
IMAPAccount gmail IMAPAccount protonmail
Host imap.gmail.com Host 127.0.0.1
User jadenprovost@gmail.com User jadenprovost@proton.me
PassCmd "PATH=/opt/homebrew/bin:$PATH bw --session $(cat $HOME/.bw_session) --nointeraction get password 'Emacs Gmail'" PassCmd "gpg -q --for-your-eyes-only --no-tty -d ~/.emacs.d/.mbsyncpass.gpg | awk '/1143/ {print $NF}'"
TLSType IMAPS Port 1143
TLSVersions +1.2 TLSType STARTTLS
AuthMechs PLAIN AuthMechs LOGIN
SystemCertificates no CertificateFile ~/.config/protonmail/bridge/cert.pem
CertificateFile /etc/ssl/certs/ca-certificates.crt
IMAPStore gmail-remote IMAPStore protonmail-remote
Account gmail Account protonmail
MaildirStore gmail-local MaildirStore protonmail-local
Subfolders Verbatim Subfolders Verbatim
Path ~/.mail/ Path ~/.mail/
Inbox ~/.mail/Inbox Inbox ~/.mail/INBOX
Trash ~/.mail/Trash SubFolders Verbatim
Channel gmail Channel protonmail
Far :gmail-remote: Far :protonmail-remote:
Near :gmail-local: Near :protonmail-local:
Patterns * ![Gmail]* !Archive Patterns * "!All Mail"
Create Both Create Both
Expunge None
SyncState * SyncState *

View File

@ -4,6 +4,10 @@
homeDirectory = "/Users/jadenmaxwell"; homeDirectory = "/Users/jadenmaxwell";
}; };
home.packages = with pkgs; [
gnupg
];
imports = [ imports = [
./shared.nix ./shared.nix
./modules/sketchybar.nix ./modules/sketchybar.nix