I showed you my source code, pls respond
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

162 lines
4.6 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. #+TITLE: Email
  2. #+AUTHOR: Christopher James Hayward
  3. #+EMAIL: chris@chrishayward.xyz
  4. #+PROPERTY: header-args:emacs-lisp :tangle email.el :comments org
  5. #+PROPERTY: header-args:shell :tangle no
  6. #+PROPERTY: header-args :results silent :eval no-export :comments org
  7. #+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil
  8. #+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil
  9. #+ATTR_ORG: :width 420px
  10. #+ATTR_HTML: :width 420px
  11. #+ATTR_LATEX: :width 420px
  12. [[../docs/images/2021-02-13-example-mu4e.gif]]
  13. Plain text email delivered via *mu*[fn:1], *mu4e*[fn:2] and *mbsync*[fn:3]. I run my *own email server*[fn:4], so your configuration may differ from mine.
  14. * Sync
  15. :PROPERTIES:
  16. :header-args: :tangle ../config/mbsyncrc :comments org
  17. :END:
  18. This is the *mbsyncrc*[fn:3] file I use to synchronize my local mail with my server.
  19. #+begin_src conf
  20. IMAPStore xyz-remote
  21. Host mail.chrishayward.xyz
  22. User chris@chrishayward.xyz
  23. PassCmd "pass chrishayward.xyz/chris"
  24. SSLType IMAPS
  25. MaildirStore xyz-local
  26. Path ~/.cache/mail/
  27. Inbox ~/.cache/mail/inbox
  28. SubFolders Verbatim
  29. Channel xyz
  30. Master :xyz-remote:
  31. Slave :xyz-local:
  32. Patterns * !Archives
  33. Create Both
  34. Expunge Both
  35. SyncState *
  36. #+end_src
  37. ** Create symbolic link
  38. The system typically expects to find this file at ~$HOME/.mbsyncrc~, but you may also specify a custom path if launching the command using arguments. I chose to symlink the default location to my repository.
  39. #+begin_src emacs-lisp
  40. (dotfiles/symlink "~/.emacs.d/config/mbsyncrc"
  41. "~/.mbsyncrc")
  42. #+end_src
  43. This repository also contains my personal encrypted auth info.
  44. #+begin_src emacs-lisp
  45. (dotfiles/symlink "~/.emacs.d/config/authinfo.gpg"
  46. "~/.authinfo.gpg")
  47. #+end_src
  48. ** Installing the software
  49. Download *mbsync*[fn:3] as part of the ~isync~ package on Ubuntu/Debian.
  50. #+begin_src shell
  51. sudo apt install -y isync
  52. #+end_src
  53. *Mu4e*[fn:2] is packaged for Ubuntu/Debian, but has a few dependencies to build for Emacs. I've had a lot of problems on multiple distributions trying to use the packaged versions. I would recommend installing it from source, which I detail here: https://chrishayward.xyz/posts/ https://chrishayward.xyz/posts/installing-mu-mu4e-from-source/
  54. #+begin_src shell
  55. sudo apt install -y mu4e libgmime-3.0-dev libxapian-dev
  56. #+end_src
  57. * Indexing
  58. :PROPERTIES:
  59. :header-args: :tangle no
  60. :END:
  61. Once mail has been synchronized you need to init, and index it using *mu*[fn:1].
  62. #+begin_src shell
  63. mbsync -a
  64. mu init --maildir="~/.cache/mail" --my-address="chris@chrishayward.xyz"
  65. mu index
  66. #+end_src
  67. * Integration
  68. After syncing and indexing the mail is ready for Emacs. Download and install *mu4e*[fn:2] and configure the *mail account*[fn:3].
  69. + Update every 5 minutes
  70. + Scale text for all devices
  71. + Sign outbound mail with GPG key
  72. + Configure mail account(s)
  73. #+begin_src emacs-lisp
  74. (use-package mu4e
  75. :load-path "~/.local/source/mu/mu4e/"
  76. :custom (mu4e-maildir "~/.cache/mail")
  77. (mu4e-update-interval (* 5 60))
  78. (mu4e-get-mail-command "mbsync -a")
  79. (mu4e-compose-format-flowed t)
  80. (mu4e-change-filenames-when-moving t)
  81. (message-send-mail-function 'smtpmail-send-it)
  82. (mml-secure-openpgp-signers '("37AB1CB72B741E478CA026D43025DCBD46F81C0F"))
  83. (mu4e-compose-signature (concat "Chris Hayward\n"
  84. "https://chrishayward.xyz\n"))
  85. :config
  86. (add-hook 'message-send-hook 'mml-secure-message-sign-pgpmime)
  87. (setq mu4e-contexts
  88. (list
  89. ;; Main
  90. ;; chris@chrishayward.xyz
  91. (make-mu4e-context
  92. :name "Main"
  93. :match-func
  94. (lambda (msg)
  95. (when msg
  96. (string-prefix-p "/Main" (mu4e-message-field msg :maildir))))
  97. :vars
  98. '((user-full-name . "Christopher James Hayward")
  99. (user-mail-address . "chris@chrishayward.xyz")
  100. (smtpmail-smtp-server . "mail.chrishayward.xyz")
  101. (smtpmail-smtp-service . 587)
  102. (smtpmail-stream-type . starttls))))))
  103. #+end_src
  104. ** Keybinding
  105. Create a keybinding to open the mail dashboard with =SPC m=.
  106. #+begin_src emacs-lisp
  107. (dotfiles/leader
  108. "m" '(mu4e :which-key "Mail"))
  109. #+end_src
  110. ** Desktop notifications
  111. Receive notifications for incoming mail via the *mu4e-alert*[fn:5] package.
  112. #+begin_src emacs-lisp
  113. (use-package mu4e-alert
  114. :after mu4e
  115. :custom (mu4e-alert-set-default-style 'libnotify)
  116. :config (mu4e-alert-enable-notifications)
  117. (mu4e-alert-enable-mode-line-display))
  118. #+end_src
  119. * Footnotes
  120. [fn:1] https://codewith.mu/en/download
  121. [fn:2] https://emacswiki.org/emacs/mu4e
  122. [fn:3] https://isync.sourceforge.io
  123. [fn:4] mailto:chris@chrishayward.xyz
  124. [fn:5] https://github.com/iqbalansari/mu4e-alert