Cannot connect to Gmail from behind VPN

When behind some VPNs, attempting to connect to a Google account via Mailspring fails:

Connection Error - Unable to connect to the server / port you provided. (SMTP)

This appears to occur when Mailspring is behind a VPN.

For anybody who have spend hours fixing this issue

It seems to me that it is caused by mailsync traffic does not work properly with VPN on OS level.
I use surge (MacOS app) as my proxy client, I turned on enhanced mode (emulates a network interface instead of letting OS redirect the traffic) and mailspring just works.

As a probable suspicion, mailsync may not use the OS networking API properly. Possibly for compatibility or features.

OAuth use localhost as callback, and that is actually a more probable cause of problem