Mutt

如何在mutt中正確配置多個賬戶

  • December 15, 2018

有很多關於這個主題的文章,沒有一篇對我有用。.muttrc 具有以下與多個帳戶相關的內容(僅使用 IMAP + 當然是 SMTP):

source "~/.mutt/account1"
folder-hook $folder 'source ~/.mutt/account1'
source "~/.mutt/account2"
folder-hook $folder 'source ~/.mutt/account2'

macro index <f2> '<sync-mailbox><enter-command>source ~/.mutt/account1<enter><change-folder>!<enter>'
macro index <f3> '<sync-mailbox><enter-command>source ~/.mutt/account2<enter><change-folder>!<enter>'

# Mailboxes
bind    index   G  imap-fetch-mail
macro   index   gi "<change-folder>=INBOX<enter>"       "Go to Inbox"
macro   index   gs "<change-folder>=$my_sent<enter>"    "Go to Sent"
macro   index   gd "<change-folder>=$my_drafts<enter>"  "Go to Drafts"
macro   index   gt "<change-folder>=$my_trash<enter>"   "Go to Trash"

帳戶文件如下(例如,對於 account1,另一個相同,但文件夾的名稱使用不同的語言):

set my_drafts             = "Drafts"
set my_drafts_noquote     = "Drafts"
set my_sent               = "Sent<quote-char><space>Items"
set my_sent_noquote       = "Sent Items"
set my_trash              = "Deleted<quote-char><space>Items"
set my_trash_noquote      = "Deleted Items"
set imap_user             = "username"
set folder                = "imaps://outlook.office365.com:993/"
set imap_authenticators   = "login"
set mbox                  = "+INBOX"
set spoolfile             = "+INBOX"
set record                = +$my_sent_noquote
set postponed             = +$my_drafts_noquote
set trash                 = +$my_trash_noquote
set smtp_url              = "smtp://username@smtp.office365.com:587"
set smtp_authenticators   = "login"
set copy                  = "yes"
account-hook $folder "set imap_user=username"

所以在開始 mutt 之後,我最終進入了收件箱account2。如果我按gsgd或者gt所有這些都將我帶到我想去的地方(已發送文件夾、草稿或垃圾箱)。然後我切換到 account on byF2並正確進入 INBOX 文件夾,但是,gs不再起作用(注意 account1 和 account2 對垃圾箱、草稿和已發送使用不同的名稱)。(它顯示的是“已發送項目”不存在,但“已發送項目”一詞是用 account2 的語言編寫的,但字元格式不正確)。gt``gd

我需要如何更正配置?

我終於找到了解決方案,所以如果有人遇到同樣的問題,答案是添加到 account1 和 account2 文件映射的 sortcuts,即 from muttrc,行

bind    index   G  imap-fetch-mail
macro   index   gi "<change-folder>=INBOX<enter>"       "Go to Inbox"
macro   index   gs "<change-folder>=$my_sent<enter>"    "Go to Sent"
macro   index   gd "<change-folder>=$my_drafts<enter>"  "Go to Drafts"
macro   index   gt "<change-folder>=$my_trash<enter>"   "Go to Trash"

還必須位於來源 accout1 和 account2 文件的末尾。似乎mutt在第一次讀取配置時填充變數的值,而不是保留變數並在每次使用實際變數值執行快捷方式時評估快捷方式的表達式。

引用自:https://unix.stackexchange.com/questions/487380