iCloud
Make an app-specific password for an iCloud Mail mailbox.
Turn on two-factor authentication
Apple only makes app-specific passwords for Apple Accounts with two-factor authentication. iCloud Mail also needs to be on in iCloud settings on one of your devices.
Create the app password
Sign in at account.apple.com, open Sign-In and Security, then App-Specific Passwords, and add one named Personal Agent Proxy.
Connect the mailbox
Connect it with iCloud and your iCloud Mail address,
such as name@icloud.com.
Changing your Apple Account password revokes app-specific passwords, which disconnects Personal Agent Proxy. Make a new one and connect the mailbox again.