Doze mode is bad.
What's even worse is that even adding an app to "exclude from optimizations" system settings *does not* fully revert the changes.
Now about AquaMail:
- It prompts the user to "exclude from optimizations"
- When the device is in Doze mode, the system will let the app check mail at most every 15 minutes, not more often
- When the device is in Doze mode, IMAP push will (for most servers) stop working
Google wants all apps to rely on GCM (Google Cloud Messaging). The mail app would have to be cloud based (and Google likes this too).
That's how you get reliable push mail even in Doze mode.
Oh wait, maybe you won't:
https://productforums.google.com/forum/#!msg/nexus/Ayd_1TOemSE/yP9Chr4UBwAJPerhaps Google engineers who wrote Google Mail for Google Android are not very familiar with latest changes to Google Android.
Or maybe they are but those are bugs in Google Mail for Google Android, or Google Android itself, or Google Cloud Messaging.
Maybe someone at Google can talk to someone at Google and work out how make a reliable mail app for Google Android.