Why not use a wallet manager like
apt install gnome-keyring secret-tool
source 'echo "$( pw=$( secret-tool lookup user <USERNAME> domain <DOMAIN> ); echo set imap_pass=\"$pw\"; echo set smtp_pass=\"$pw\" )" |'
Store your imap and smtp passwd:
secret-tool store --label=imap user <USERNAME> domain <DOMAIN>
You could choose your own label if you wanted to.
Look up your creds using a shell:
secret-tool lookup user <USERNAME> domain <DOMAIN>
Fire up your [neo]mutt, connect & login to your imap srv. Enjoy.
This solution has advantages over gpg-based ones: it integrates well and there's no additional file left layin' around.
libsecret or directly
gnome-keyring as a
git credential-helper as in git with libsecret and git with gnome-keyring. Both helpers need manual compilation. Yes, it's a bit awkward but it is working great.