Query on mbsync for macOS

The wheels grind slowly here at Irreal but they do grind. I’m in the final stages of moving my email to Emacs in my neverending quest to run everything in Emacs. My specific intent is to run mu4e as my client and have mbsync take care of retrieving and syncing emails for my Apple mail account.

Sadly, I can’t get mbsync to connect with the Apple IMAP server. The relevant part of my .mbsyncrc is

IMAPAccount icloud
Host IMAP.mail.me.com
User XXX
PassCmd "security find-generic-password -s mbsync-icloud-password -w"
Port 993
SSLType IMAPS
SSLVersions TLSv1.2
AuthMechs Login
#CertificateFile /usr/local/share/certs/ca-bundle.crt

when I run this with mbsync -D icloud, I get

...
Logging in...
>>> 1 LOGIN <user> <pass>
1 NO [AUTHENTICATIONFAILED] Authentication failed
IMAP command 'LOGIN <user> <pass>' returned an error: NO [AUTHENTICATIONFAILED] Authentication failed

It makes no difference whether or not the CertificateFile line in the configuration is commented out. The security function on the PassCmd line does return my icloud password and even entering the password itself on a PASS line doesn’t work. It makes no difference whether the USER line is just my user name or my full email address.

I’ve consulted DuckDuckGo but I can’t find any examples of setting things up for macOS. If anyone has a working mbsync configuration for talking to Apple’s IMAP server, I’d really like to hear from you. Please leave a comment if you have any wisdom to impart.

UPDATE [2017-03-25 Sat 12:54] Andy Bold figured out the main problem. Since Sierra (I think) introduced two-factor authentication, you need to generate an application specific password for this sort of thing. Once I did that, mbsync connected to the Apple IMAP server without a problem. Now I’m dealing with the notoriously finicky Apple Mail service to get things downloaded. I’ll write up my adventures when I’m done.

This entry was posted in General and tagged . Bookmark the permalink.