From https://apple.stackexchange.com/a/159510/76470 :
I found SleepWatcher, a free tool that allows to run a script when the screen goes to sleep or wakes up.
After installing it, you can link a shell script that is run on one of the available events (which include dim screen, wake up screen, computer sleep, wake up computer and some more). From the shell ...
After tests, I think the least buggy method for Apple's bad implementation is setup gmail with pop3 method in Mac Mail.app and set rules to delete all incoming emails.
There are no rules for iPhone but we can turn off auto fetching.