I’ve been trying to track down the solution to my issue as well. I noticed that running the connectivity test gave inconsistent results, sometimes within the same day, and lots of timeout errors. This was after making no changes, so sometimes it works, other times not. My hosting assured me that they are not blocking any of the ports from the test and I too was using Gmail and OAuth 2. What you are saying, however, would make sense, that when mine started failing it was one of the blocked connections, it would also explain why it would happen so inconsistently.
I’ve implemented your solution and everything is working at the moment. How can I know for sure that it will stay this way? Or do I just keep checking? The client is getting a bit agitated with this reoccurring issue.
Thanks for all the info!