Account Command π₯#
Since: NeoMutt 2022-05-16
Introduction#
NeoMutt provides dedicated config options to specify credentials for network servers.
These include $imap_user, $imap_pass, $smtp_user, $smtp_pass, etc.
There are a few downsides to this approach.
For one thing, their use encourages storing usernames and passwords in plain text inside a NeoMutt config file.
People have come up with solutions to this, including using GPG-encrypted files and populating my_ variables via external scripts through source "/path/to/script|".
However, once the variables are set, the secrets can be inspected with the :set command.
Also, because these config options are not account-specific, they have been the cause of a proliferation of ways to mimic per-account setups using a combination of convoluted hooks and macros to modify them on folder change or on a keypress.
The goal of this feature is to get rid of most _user and _pass variables.
To do so, it provides a way of specifying an external command that NeoMutt will call to populate account credentials for network servers such as IMAP, POP, or SMTP.
The external command is called with a number of arguments indicating the known properties of the account such as the account type and hostname; the external command provides NeoMutt with a list of additional properties such as username and password.
Usage#
Set
$account_commandto point to your external script:set account_command = "/path/to/my/script.sh"
NeoMutt will call the specified program with the following key-value command line arguments:
--hostname valβ the network host name of the service--username valβ the username for the account. This might be specified in the URL itself, e.g.,set folder="imaps://me@example.com@example.com"or with a dedicated existing variable, e.g.set imap_user=me@example.com.--type valβ the type of the account, one ofimap,pop,smtp,nntp, with an optional trailingsif SSL/TLS is required.
The script must respond by printing to stdout a number of
key: valuelines. NeoMutt currently recognizes the following keys:loginusernamepassword
Because password can contain any characters, including spaces, lines are expected to match the regex ^([[:alpha:]]+): (.*)$ exactly.
Credits#
Pietro Cerutti