How do programs access ~/Library/Mail under OSX 10.14 (Mojave) After upgrading to 10.14, I am unable to access the ~/Library/Mail directory, either as the user or as root.

[~/Library/Mail 14:01:42]$ ls -l
ls: .: Operation not permitted
[~/Library/Mail 14:04:11]$


So that's pretty weird. It happens even if I am root.

No system flags are set on the directory.

So presumably, this is another system integrity or sandboxing thing. Unfortunately, I have code that wants to access the sqlite3 database inside the ~/Library/Mail directory.  So how do I grant my software access to my mail?

This seems to be related to the 10.14 privacy protections.
Full Disk Access

Add your application or tool to the Full Disk Access list within System Preferences > Security &amp; Privacy.

This is related to the new macOS Privacy Protections in 10.14, aka Mojave.

If you want programs launched from Terminal to be able to access ~/Library/Mail, you will need to add them to the Full Disk Access list (below). I originally added Terminal and still couldn't access the folder. It turns out that I use iTerm2, and not Terminal. That had to be added also.