If you are using an email provider with two-factor authentication enabled, you must use an “Application Specific Password”. Otherwise, your regular email password will work as expected.
Apple:
https://support.apple.com/en-us/HT204397
Google/Gmail:
You can use OAuth(Google authentication) to easily connect to google but if you choose to do so using IMAP you would need to follow the below steps to get an app password:
- https://support.google.com/accounts/answer/185833?hl=en-GB
- In Select app create new app 'EAP'
- In Select device choose ‘Mac’
- Copy the app password generated