fix: mutt spoolfile set after other folder options

- Fix mutt-sorcerer printing an invalid glob
- Encrypt postponed messages
- Set different folders based on folder regexp
- Use mailboxes when offline
This commit is contained in:
Ben Grande 2025-01-08 17:08:51 +01:00
parent b7d290de79
commit a76215014f
No known key found for this signature in database
GPG Key ID: 00C64E14F51F9E56
7 changed files with 59 additions and 38 deletions

View File

@ -8,7 +8,7 @@ Copyright: 2023 Benjamin Grande M. S. <ben.grande.b@gmail.com>
License: MIT
Files: files/mutt/.config/mutt/sample/*.example
Copyright: 2024 Benjamin Grande M. S. <ben.grande.b@gmail.com>
Copyright: 2024 - 2025 Benjamin Grande M. S. <ben.grande.b@gmail.com>
License: GPL-3.0-or-later
Files: files/sh/.config/less/lesskey-old

0
files/mutt/.cache/mutt/.gitignore vendored Normal file
View File

View File

@ -1,7 +1,10 @@
# SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. <ben.grande.b@gmail.com>
# SPDX-FileCopyrightText: 2023 - 2025 Benjamin Grande M. S. <ben.grande.b@gmail.com>
#
# SPDX-License-Identifier: AGPL-3.0-or-later
## Encryption
set ssl_force_tls = yes
## IMAP
set folder = "imaps://imap.$my_server"
set imap_user = "$my_user"
@ -20,8 +23,5 @@ set pop_last = yes
## SMTP
set smtp_url = "smtps://$my_user@smtp.$my_server"
set smtp_pass = "$my_pass"
set realname = "$my_name"
set ssl_starttls = yes
set ssl_force_tls = yes
## vim: ft=muttrc

View File

@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. <ben.grande.b@gmail.com>
# SPDX-FileCopyrightText: 2023 - 2025 Benjamin Grande M. S. <ben.grande.b@gmail.com>
#
# SPDX-License-Identifier: AGPL-3.0-or-later
@ -31,6 +31,7 @@ auto_view text/plain text/html
## Option 'use_envelope_from' does not work reliably, force Message-ID
## format to remove hostname from the header.
set message_id_format = "<%z@%r%r>"
set realname = "$my_name"
set from = "$my_user@$my_server"
set use_from = yes
set fast_reply = yes
@ -49,13 +50,18 @@ set forward_format = "Fwd: %s"
set forward_quote
## Cache
set spoolfile = "+INBOX"
## GMail duplicates sent mails if the 'record' option is set.
#set record = "+Sent"
unset record
## Favor local cache for speed, security and privacy.
set spoolfile = "+INBOX"
set mbox = "~/.cache/mutt/archived"
set record = "~/.cache/mutt/sent"
set postponed = "~/.cache/mutt/postponed"
## 'record' has to also be set inside the hook else it is unset.
folder-hook '.*(\.|@)?(gmail|googlemail)\.com(/.*)?' 'set \
spoolfile = "+INBOX" \
mbox = "+[Gmail]/All Mail" \
record = "~/.cache/mutt/sent" \
postponed = "~/.cache/mutt/postponed" \
'
set header_cache = "~/.cache/mutt/headers"
set message_cachedir = "~/.cache/mutt/messages"
set certificate_file = "~/.cache/mutt/certificates"
@ -65,6 +71,7 @@ set history_remove_dups = yes
set save_history = 1
## Alias
alias me $realname <$from>
alias me $realname <$from>
alias myself $realname <$from>
## vim: ft=muttrc

View File

@ -1,6 +1,6 @@
# SPDX-FileCopyrightText: 2020 Wojtek Porczyk <https://woju.eu>
# SPDX-FileCopyrightText: 2020 Miguel Jacq <https://mig5.net>
# SPDX-FileCopyrightText: 2023 - 2024 Benjamin Grande M. S. <ben.grande.b@gmail.com>
# SPDX-FileCopyrightText: 2023 - 2025 Benjamin Grande M. S. <ben.grande.b@gmail.com>
#
# SPDX-License-Identifier: GPL-3.0-or-later
@ -12,18 +12,29 @@ send-hook "~t ^security@qubes-os\\.org$" "set pgp_autoinline=no crypt_autoencryp
send-hook "~t @invisiblethingslab\\.com" "set pgp_autoinline=no crypt_autoencrypt=yes"
send-hook "~t @googlegroups\\.com" "set pgp_autoinline=yes crypt_autoencrypt=no"
## General Encryption and Signature
set crypt_autopgp = yes # Use PGP for encryption
set crypt_autoencrypt = no # Encryption is user preference
set crypt_autosign = yes # Sign all messages
set crypt_replyencrypt = yes # Encrypt replies to encrypted messages
set crypt_replysignencrypted = yes # Sign replies to encrypted messages
set crypt_verify_sig = yes # Verify the opened message signature
set crypt_use_gpgme = no # GPGME interferes with split-gpg
## General Encryption and Sign
set crypt_autopgp = yes # Use PGP for encryption
set crypt_autoencrypt = no # Encryption is user preference
set crypt_autosign = yes # Sign all messages
set crypt_replyencrypt = yes # Encrypt replies to encrypted messages
set crypt_replysignencrypted = yes # Sign replies to encrypted messages
set crypt_verify_sig = yes # Verify the opened message signature
set crypt_use_gpgme = no # GPGME interferes with split-gpg
set crypt_protected_headers_read = yes # Display encrypted headers
set crypt_protected_headers_write = yes # Encrypt headers when composing
set crypt_protected_headers_save = no # Save headers in plain text to disk
## Encrypting a message (without signing) provides data confidentiality but
## lacks authentication and integrity, therefore only makes sense when
## postponed messages are stored on a remote server, as a local attacker can
## just wait to read the message unencrypted.
## Mutt does not provide a sign option for postponed messages, readers should
## still inspect postponed messages fetched from remote servers for tampering.
## As Mutt does not provide an option to sign postponed messages, readers
## should still inspect them when fetched from remote servers for tampering.
## Self-encrypt postponed messages marked for encryption.
set postpone_encrypt = yes
## PGP
set pgp_autoinline = no # Inline is user preference
set pgp_use_gpg_agent = yes # Avoid prompting for a passphrase

View File

@ -1,15 +1,24 @@
## Copy to ~/.config/mutt/offline.muttrc and modify.
## Copy to ~/.config/mutt/90-offline.muttrc and modify.
set read_only = yes
unset spoolfile
unset folder
unset smtp_url
## Avoid connection tests.
unset folder smtp_url pop_host folder spoolfile mbox record postponed
set imap_passive = yes
set sendmail = "env EMAIL_CONN_TEST=x /usr/libexec/msmtp/msmtpq/msmtpq"
set sendmail_wait = 0
## Reading and Composing
set read_only = yes
set folder = "~/mail"
set spoolfile = "+INBOX"
set mbox = "~/.cache/mutt/archived"
set record = "~/.cache/mutt/sent"
set postponed = "~/.cache/mutt/postponed"
mailboxes ! + `for dir in ~/mail/*; do \
test -d "${dir}" || continue; \
dir="${dir##*/}"; \
case "${dir}" in .|..) continue;; esac; \
printf '%s' "\"+${dir}\" "; \
done`
## Sending
set sendmail = "env EMAIL_CONN_TEST=x /usr/libexec/msmtp/msmtpq/msmtpq"
set sendmail_wait = 0
## vim: ft=muttrc

View File

@ -1,6 +1,6 @@
#!/bin/sh
##
## SPDX-FileCopyrightText: 2024 Benjamin Grande M. S. <ben.grande.b@gmail.com>
## SPDX-FileCopyrightText: 2024 - 2025 Benjamin Grande M. S. <ben.grande.b@gmail.com>
##
## SPDX-License-Identifier: AGPL-3.0-or-later
##
@ -13,10 +13,10 @@ credentials_file="${HOME}/.muttrc-credentials.local"
aliases_file="${HOME}/.muttrc-aliases.local"
local_file="${HOME}/.muttrc.local"
## source_redable(): do not require that the file exists in the first place.
## source_existent(): do not require file existence.
source_existent(){
for file in "${@}"; do
if test -f "${file}"; then
if test -f "${file}" && test -r "${file}"; then
printf '%s\n' "source \"${file}\""
fi
done
@ -26,10 +26,4 @@ source_existent(){
## Source files that must exist, let mutt fail otherwise.
printf '%s\n' "source \"${credentials_file}\""
## PWD is inherited from the muttrc that called this script.
for file in *.muttrc; do
printf '%s\n' "source \"${file}\""
done
unset file
source_existent "${aliases_file}" "${local_file}"
source_existent ./*.muttrc "${aliases_file}" "${local_file}"