Αὐτὸς ὁ ὁδηγὸς παρέχει γρήγορη ρύθμιση γιὰ διαμόρφωση Notmuch μὲ GNU Ἤμαξ γιὰ χειρισμὸ πολλαπλῶν διευθύνσεων ἠλεκτρονικοῦ ταχυδρομείου καὶ ἐνεργοποίηση αὐτόματης κρυπτογράφησης.
Τὸ Notmuch ὑπῆρξε ἐξαιρετικὰ χρήσιμο γιὰ μένα τὸν περασμένο χρόνο, καὶ ἐλπίζω αὐτὸς ὁ ὁδηγὸς νὰ βοηθήσει νέους χρήστες νὰ ξεπεράσουν τὰ ἀρχικὰ ἐμπόδια.
Ἤμαξ Notmuch μὲ πολλαπλὲς διευθύνσεις καὶ αὐτόματη κρυπτογράφηση
Σημειώσεις βίντεο:
Σύνοψις
- Ἐπίδειξη ροῆς ἐργασίας ἠλεκτρονικοῦ ταχυδρομείου Ἤμαξ μὲ
notmuch.el.
Γιατί notmuch
- Ἐνσωματωμένη ὑποστήριξη Ἤμαξ, μὲ
notmuch.el.- Πακέτα ὅπως ol-notmuch φέρνουν ἐνσωμάτωση μὲ τὸ ὑπόλοιπο οἰκοσύστημα Ἤμαξ.
- Τὸ Notmuch εἶναι
σύστημα βασισμένο σὲ ἐτικέτες. Δὲν βασίζεσαι στὸν πάροχο ἠλεκτρονικοῦ ταχυδρομείου σου γιὰ κανόνες φίλτρων κ.λπ. γιὰ νὰ ὀργανώσεις τὴν ἀλληλογραφία σου σὲ ξεχωριστὰ γραμματοκιβώτια.- Πράγμα ποὺ εἶναι ἀναποτελεσματικὸ ἐξαρχῆς ὅταν δουλεύεις μὲ χιλιάδες++ μηνύματα ἠλεκτρονικοῦ ταχυδρομείου.
- Αὐτὸ ἐπίσης κάνει εὐκολότερη τὴ μετάβαση σὲ νέο πάροχο ἠλεκτρονικοῦ ταχυδρομείου.
- Τοπικὴ ἀποθήκευση ἀλληλογραφίας.
- Ἐξαιρετικὴ ἐπίδοση γιὰ φιλτράρισμα καὶ ἀναζήτηση μέσα ἀπὸ ἑκατοντάδες χιλιάδες μηνύματα.
Ὑποθέσεις ποὺ κάνω γιὰ αὐτὸ τὸ βίντεο
Ἔχεις λειτουργικὴ διαμόρφωση Ἤμαξ
Ὁ πάροχος ἠλεκτρονικοῦ ταχυδρομείου σου ὑποστηρίζει ἀνάκτηση καὶ ἀποστολὴ ἀλληλογραφίας μέσω ἐφαρμογῶν τρίτων
- Ἤδη ξέρεις πῶς νὰ ρυθμίσεις
isync/mbsyncγιὰ ἀνάκτηση μηνυμάτων ἠλεκτρονικοῦ ταχυδρομείου ἀπὸ ἀπομακρυσμένο διακομιστή. - Ὁ πάροχος ἠλεκτρονικοῦ ταχυδρομείου σου προσφέρει διαπιστευτήρια
smtpγιὰ χρήση ἐφαρμογῶν τρίτων.- Προσωπικὰ συνιστῶ νὰ δοκιμάσεις τὸ
purelymail.comκοστίζει μόνο 10$/χρόνο καὶ προσφέρει καλὴ ὑπηρεσία.
- Προσωπικὰ συνιστῶ νὰ δοκιμάσεις τὸ
Παράδειγμα διαμόρφωσης isyncrc ~/.config/isyncrc
IMAPAccount gmail
Host imap.gmail.com
Port 993
User [email protected] # Change this to your username.
PassCmd "pass gmail/account" # Change this to a command that returns your password.
TLSType IMAPS
TLSVersions +1.2
CertificateFile /etc/ssl/certs/ca-certificates.crt
IMAPStore gmail-remote
Account gmail
MaildirStore gmail-local
Path ~/Mail/gmail/
Inbox ~/Mail/gmail/Inbox
Trash ~/Mail/gmail/Trash
SubFolders Verbatim
Channel gmail
Far :gmail-remote:
Near :gmail-local:
Patterns *
Expunge None
CopyArrivalDate yes
Sync All
Create Both
SyncState *
Μετὰ τὴν προσαρμογὴ τῆς παραπάνω διαμόρφωσης, τρέξε mbsync -a γιὰ νὰ
συγχρονίσεις τὸ ἀπομακρυσμένο γραμματοκιβώτιο τοπικά.
Ρύθμιση notmuch
Πρώτη ἐγκατάσταση
- Μετὰ τὴν ἐγκατάσταση notmuch γιὰ πρώτη φορά, τρέξε
notmuch setupγιὰ διαδραστικὴ ρύθμιση.
Δημιούργησε ~/.scripts/notmuch-hook.sh
- Σενάριο Bash ποὺ θὰ φιλτράρει/ἐπισημαίνει τὴν ἀλληλογραφία σου
Παράδειγμα:
#!/bin/sh
notmuch new
# Add +inbox tag to a specific alias/address
notmuch tag +inbox -- to:[email protected]
#Sent messages, change this to your mail addresses
notmuch tag -unread -new -inbox +sent -- from:*@mydomain.org or from:*@mydomain.com or from:[email protected]
# Example for Emacs-devel
notmuch tag +emacs-devel -new -inbox -- from:[email protected] or to:[email protected]
# Example for Github
notmuch tag +github -- from:*github.com
# Filter based on other tags, such as drafts
notmuch tag -inbox -sent -inbox -- tag:draft
Διαμόρφωση Ἤμαξ
Notmuch
(use-package notmuch
:config
(defun thanos/notmuch-update--command (new-buffer)
(let ((default-directory "~/.scripts/")) ;; Directory where notmuch script is located.
(async-shell-command "mbsync -a; ./notmuch-hook.sh" new-buffer)))
(defun thanos/notmuch-update ()
(interactive)
(let* ((buffer (generate-new-buffer "*notmuch update*"))
(height (max 5 (truncate (* (frame-height) 0.1))))
(window (split-window-vertically (- height))))
(with-selected-window window
(switch-to-buffer buffer)
(let ((proc (thanos/notmuch-update--command buffer)))
(set-process-sentinel
(get-buffer-process buffer)
(lambda (process event)
(when (memq (process-status process) '(exit signal))
(delete-window (get-buffer-window (process-buffer process)))
(kill-buffer (process-buffer process)))))))))
(defun thanos/notmuch-search ()
"Custom notmuch-search wrapper, that makes sure we have newest mail first."
(interactive)
(let ((query (notmuch-read-query "Notmuch search: ")))
(notmuch-search query nil)))
;; Configure saved searches to your liking, here's an example:
(setf notmuch-saved-searches
`((:name "Week's Inbox" :query "tag:inbox date:7d..today" :sort-order newest-first
:key ,(kbd "i"))
(:name "Inbox" :query "tag:inbox" :sort-order newest-first :key ,(kbd "I"))
(:name "Unread" :query "tag:unread" :sort-order newest-first :key ,(kbd "u"))
(:name "Today's message" :query "tag:inbox date:today"
:sort-order newest-first :key ,(kbd "t"))
(:name "sent" :query "tag:sent" :sort-order newest-first :key ,(kbd "s"))
(:name "drafts" :query "tag:draft" :sort-order newest-first :key ,(kbd "d"))
(:name "all mail" :query "*" :sort-order oldest-first :key ,(kbd "a"))))
;; Tag format configuration
(setf notmuch-tag-formats
'(("unread" (propertize tag 'face 'notmuch-tag-unread))))
:bind (("C-x m" . notmuch-hello)
:map notmuch-hello-mode-map
("u" . notmuch-hello-update)
("U" . thanos/notmuch-update)
("s" . thanos/notmuch-search)
:map notmuch-search-mode-map
("u" . notmuch-refresh-all-buffers)))
smtpmail
- Αὐτὴ ἡ διαμόρφωση χρησιμοποιεῖται γιὰ ἀποστολὴ μηνυμάτων ἠλεκτρονικοῦ ταχυδρομείου ἀπὸ πολλαπλὲς
διευθύνσεις· βεβαιώσου ὅτι ἔχεις ἀποθηκευμένο τὸν κωδικὸ
πρόσβασης στὸ
~/.authinfo.gpgποὺ ὁ Ἤμαξ θὰ χρησιμοποιήσει ἐκ προεπιλογῆς.
(use-package smtpmail
:config
;; Default credentials
(setf smtpmail-smtp-user (auth-source-pass-get "user" "gmail/user") ;; This is not your password, just the username. Emacs will search for your pw in ~/.authinfo.gpg.
smtpmail-smtp-server "smtp.gmail.com"
smtpmail-smtp-service 465 ;; Adjust this to your mail provider port if needed
smtpmail-stream-type 'ssl
message-send-mail-function 'smtpmail-send-it
message-signature "My signature")
(defun thanos/mail-config-hook ()
(let ((from (mail-fetch-field "From"))
(public "<[email protected]>")
(gmail "<[email protected]>"))
(cond ((string-match public from)
(setf smtpmail-smtp-user (auth-source-pass-get "user" "purelymail/thanosapollo")
smtpmail-smtp-server "smtp.purelymail.com"))
((string-match gmail from)
(setf smtpmail-smtp-user "[email protected]"
smtpmail-smtp-server "smtp.gmail.com")))))
;; You can use :hook instead, but I prefer add-hook under :config personally.
(add-hook 'message-send-hook #'thanos/mail-config-hook))
mml-sec
(use-package mml-sec
:config
(defun gpg-list-emails-available ()
"Return a list of trusted emails.
Parses output of `gpg --list-keys --with-colons' command into a
list of emails."
(let* ((command "gpg --list-keys --with-colons")
(output (shell-command-to-string command))
(lines (split-string output "\n" t))
(emails '()))
(dolist (line lines)
(when (string-prefix-p "uid:" line)
(when (string-match "<\\([^>]+\\)>" line)
(let ((email (downcase (string-trim (match-string 1 line)))))
(push email emails)))))
(delete-dups emails)))
(defun thanos/mail-list-recipients-from-buffer ()
"Get the list of recipients from the current email buffer."
(save-excursion
(goto-char (point-min))
(let ((to (or (mail-fetch-field "To") ""))
(cc (or (mail-fetch-field "Cc") ""))
(bcc (or (mail-fetch-field "Bcc") ""))
recipients)
(setq recipients (concat to ", " cc ", " bcc))
;; Remove empty strings from the result
(delq nil
(mapcar (lambda (addr)
(let ((clean-addr (string-trim addr)))
(when (not (string-empty-p clean-addr))
(downcase
(if (string-match "<\\([^>]+\\)>" clean-addr)
(string-trim (match-string 1 clean-addr))
clean-addr)))))
(split-string recipients "," t))))))
(defun thanos/mail-sign-encrypt ()
"Auto-encrypt if all recipients have keys, else just sign."
(let ((trusted-emails (gpg-list-emails-available))
(recipients (thanos/mail-list-recipients-from-buffer)))
(if (cl-every (lambda (r) (member r trusted-emails)) recipients)
(progn
(message "Encrypting message.")
(mml-secure-message-sign-encrypt))
(progn
(message "Just signing message.")
(mml-secure-message-sign)))))
(add-hook 'message-send-hook #'thanos/mail-sign-encrypt)
:custom
(mml-secure-openpgp-signers '("62B758D0F6719938BC09CECA339F736C3A720928"))) ;; Change this to your own key!