El-Cap Mail app intermittent IMAP connection issues The issues started occurring after upgrade to 10.11 but not sure if related or not.

I have 2 gmail accounts defined on my Mail app. Most of the time (around 70% or so) all is healthy.



But every few minutes, the alert signs show up next to both of the accounts. The connection doctor points the blame at IMAP



This lasts for a while, usually a few minutes. I immediately check my internet connection by pinging various public IPs - all is rock solid. After a while this goes away.

Any idea why this may happen and how I can troubleshoot? I'm tending to not suspect an account setup issue as all works well most of the time. BTW - both of the accounts were set up very basic - just selected Gmail as the account type and added user and password. Did not mock around with anything else more advanced.

Thank you.
This problem is reported so often that it is likely there are multiple causes.  But after many months of putting up with this exact issue, here is what worked for me:

Mail => Preferences => General => Check for new messages

The default setting is Automatically

Change this to Every 5 minutes

I imagine anything will work except "Automatically".  My guess is that the Automatic option leaves a connection open to the imap server, and this is what gets screwed up.  I have not tested but it also possible the problem occurs because I click the manual download button while Mac Mail is set to Automatic download.  All I know is that this has been a continuing annoyance for a long time and with this change, it works.