I'm running macOS High Sierra 10.13.4 on a 2009 iMac. I've got the screen set to go to sleep after 1 hour, and the computer to never sleep (it's running Indigo, jabberd, iTunes, and Server, so I don't want it to sleep, ever).
The computer never appears to sleep -- I can access my services regularly, even after not having touched the machine for days.
However, Mail does appear to sleep. I've got several rules set, and I can tell that Mail has snoozed off when I open Mail on my iPhone or iPad and see a ton of messages in my inbox that should've been filed elsewhere.
I can SSH onto the system, and can do anything I like, but while the system is awake, the Mail app doesn't wake up. I go back to the iMac (even remotely through a shared desktop) or move the mouse or tap on the keyboard, and *poof*, the messages get filtered properly -- as observed on iOS, remotely. Mail has awoken.
I've tried setting the following:
defaults write com.apple.mail.plist NSAppSleepDisabled -bool YES
and while I first thought it might be working, was proven wrong today.
pmset -g assertions
shows that PreventUserIdleSystemSleep is set to 1 and NetworkClientActive is 1, too.
shows that the system is prevented from sleeping by a ton of serverd processes.
What am I missing? Is Mail really going to sleep? Does it have some other strange mode it can get into that will prevent it from running its rules?
Try disabling App Nap altogether
How is Mail > Preferences > Settings > General > Check for new messages set? It's possible that "Automatically" includes some logic that results in "but not so obsessively unless we know the user is around" or some such. Perhaps setting it to a fixed interval would help?
Failing that, what about running `caffeinate` from the Terminal to ensure the system remains awake?
Don't want you to think I'm not responding -- I've tried @datafornothinandbitsforfree's suggestion to disable AppNap system-wide, and not had another recurrence since then. However, another variable has changed, in that I've wound up using the system multiple times a day since implementing that change. So, I've changed 2 variables, hence the test results are inconclusive.
I'll report back after this batch of tasks is done and the system usage has quiesced again. If this doesn't work, then I'll try Dave's suggestion (and yeah, it's currently set to Automatically.)