I'm running macOS Mojave 10.14. Mail.app and our Exchange server periodically quit talking to one another. The primary symptom of this is that the Inbox shows nothing even though webmail and my iPhone show plenty of messages.
Prior to the upgrade to Mojave, I was able to shut down Mail.app, delete the ~/Library/Mail directory and restart Mail.app. This caused Mail to re-download everything from Exchange and we were fine for a while. I even pruned my Exchange account so it wouldn't be a multiple GB download every time this happened, hoping that maybe an old message was causing something to get hung up.
So, I tried to do this again, but this time, I got rewarded with:
wowbagger:Library brianm$ rm -rf Mail rm: Mail: Operation not permitted
ls -ld@ the Mail directory:
wowbagger:Library brianm$ ls -ld@ Mail drwxr-xr-x@ 4 brianm staff 128 Oct 5 11:26 Mail com.apple.quarantine -1
Okay, the regular UNIX permissions look fine, but it also has an extended attribute. If I delete that attribute, I should be able to then delete the directory.
wowbagger:Library brianm$ xattr -d com.apple.quarantine Mail xattr: [Errno 1] Operation not permitted: 'Mail'
Hmm. What if I clear all attributes?
wowbagger:Library brianm$ xattr -c Mail xattr: [Errno 1] Operation not permitted: 'Mail'
sudo doesn't help any of these commands. For example:
wowbagger:Library brianm$ sudo xattr -c Mail Password: xattr: [Errno 1] Operation not permitted: 'Mail'
Other directories also have that
So, how do I either fix what's going on in Mail or somehow delete that Mail directory so it will rebuild it from scratch?