You might want to store application specific passwords in the Keychain.
Here is how to do it in .mbsyncrc
https://gist.github.com/eddieh/8c853c6cf8ffb3ad87e0720eb50f8...
And here is how to do it in .msmtprc
https://gist.github.com/eddieh/5b4df4a8a98ea202e6ebb020871b0...