iCloud not working with app password

I’m trying to set up an iCloud account but I’m getting an error even when using an app password?

connect <mailcore::IMAPSession:004FF954>
* OK [CAPABILITY XAPPLEPUSHSERVICE IMAP4 IMAP4rev1 SASL-IR AUTH=ATOKEN AUTH=PLAIN AUTH=ATOKEN2] (2412B71-032347a9ddb8) st43p00im-tygg10071001.me.com
ssl connect imap.mail.me.com 993 2
OpenSSL version: OpenSSL 1.1.0f  25 May 2017
connect ok
login
1 LOGIN "email" *********
1 NO [AUTHENTICATIONFAILED] Authentication Failed

I’m trying to set up an iCloud account, but I’m getting an error even when using an app password.
Me too. Funny.

iCloud IMAP has some quirks. A few things to double-check:

  1. Use an App-Specific Password — this is required since Apple enables 2FA by default. Generate one at appleid.apple.com under Security > App-Specific Passwords.

  2. Use the correct server settings:

    • IMAP server: imap.mail.me.com, port 993, SSL
    • SMTP server: smtp.mail.me.com, port 587, STARTTLS
  3. Username must be your full @icloud.com address (or @me.com/@mac.com), not just the part before the @.

  4. Make sure IMAP is enabled in iCloud settings — go to iCloud.com > Mail > Settings gear icon > Preferences > IMAP, and ensure it’s turned on.

If you’re still seeing AUTHENTICATIONFAILED after checking all of the above, try generating a fresh app-specific password — they occasionally need to be regenerated.