iCLOUD AND APP-SPECIFIC PASSWORDS
If you are using a non-Apple app to access
your email or other
facilities, you are now required to use an 'app-specific' password in
place of your normal iCloud password. In order to do this you need to
set up two-factor authentication for your Apple ID, and for this you
need to have either a Mac running El Capitan or above, or an iOS device
running iOS9 or above.
If you are unable to set up two-factor authentication you should set up 2-step verification and use that to create an app-specific password (see link below) . Then go to http://appleid/apple.com , select 'Password and Security'; click 'Generate an App-Specific Password' and follow the instructions. Once you have the password, copy it and paste it into the password field in the application instead of your usual iCloud password. You should also keep a note of it (though you can generate a new one if required).
You will need to nominate a 'trusted device' - any phone capable of receiving SMS messages. There will be a 2-day wait before you can complete the process.
(A particular caveat (about 2-step only) - you will be issued with a 'Recovery Key' in case you lose your 'trusted device'. Make sure to write this down and keep it in a safe place; if you lose both it and your trusted device you will be permanently locked out of your ID. You'd be surprised at the number of people who've posted on the Apple forums that they've got themselves into just that position.)
Incidentally, Mail on Snow Leopard and earlier is not recognized as an Apple application because it's pre-iCloud and doesn't have the necessary facilities, so it will be necessary to obtain an app-specific password for that.