Using Mutt and gnome-keyring
I've used various tools over the years to store my email passwords in my desktop environment's secure password storage system. Currently that is gnome-keyring which implements the Secret Service API. The secret-tool program can be used to integrate password storage with programs like Mutt, which don't use the API directly.
Storing a password:
secret-tool store --label='mutt example' mutt-account imap://user@example.com@imap.example.com/
If your password contains a $ character, you have to escape it in the stored value as \$, or else mutt will truncate the value it reads from the keyring!
Retrieving the password:
set folder = imap://user@example.com@imap.example.com/ set imap_pass = `secret-tool lookup mutt-account imap://user@example.com@imap.example.com/ set record = + set postponed = +Drafts set spoolfile = + set smtp_url = smtp://user@example.com@smtp.example.com:587/ set smtp_pass = `secret-tool lookup mutt-account imap://user@example.com@imap.example.com/ # stop Mutt prompting to move read mail from spoolfile to (unused) mbox set nomove