相关疑难解决方法(0)

我如何才能为 mutt 中的唯一特定收件人进行 GPG 加密?

我正在尝试设置一个发送挂钩,以便在发送给特定收件人时启用 gpg 加密,但如果它也发送给其他收件人,则禁用加密。但是,当特定收件人在收件人列表中的任何位置时,发送挂钩似乎会触发,而不管其他人是否在场。

理想情况下,如果转到 ,我会加密foo@bar.com,但如果转到 ,则不会加密foo@bar.com, not@this.com, or@whatever.com。笨蛋手册

当发生多个匹配时,[send-hook] 命令按照它们在 muttrc 中指定的顺序执行。

因此,我将以下内容放入我的 muttrc.conf 文件中。如果邮件发送到foo@bar.com,则启用自动加密。但是,如果收件人不是foo@bar.com,则取消设置自动加密。

send-hook . unset crypt_autoencrypt
send-hook "!~l ~t ^foo@bar\\.com$" "set crypt_autoencrypt"
send-hook "!~l !~t ^foo@bar\\.com$" "unset crypt_autoencrypt"
Run Code Online (Sandbox Code Playgroud)

但是,它似乎不起作用。似乎发送钩子似乎并没有分别解析每个单独的收件人。即使我将邮件发送到foo@bar.com, not@this.com,mutt也会尝试对其进行加密。

解决方法

我可以通过一个非常丑陋的黑客来解决这个问题。

send-hook . unset crypt_autoencrypt
send-hook "!~l ~t ^foo@bar\\.com$" "set crypt_autoencrypt"
send-hook "!~l ~t [^r]\\.com$" "unset crypt_autoencrypt"
Run Code Online (Sandbox Code Playgroud)

如果我将电子邮件发送到前面.com有非r字符的地址,则它不会加密。显然有很多…r.com地址不是foo@bar.com,所以我必须按如下方式扩展第三行。

send-hook "!~l ~t '([^r]\\.com|[^a]r\\.com)$" "unset crypt_autoencrypt" …
Run Code Online (Sandbox Code Playgroud)

mutt

5
推荐指数
1
解决办法
282
查看次数

标签 统计

mutt ×1