I do something like this in my .muttrc. It was showing up in documentation iirc, as the typical way to store credentials for mutt.