Yesterday I helped a friend who had a problem where her outgoing email account (SMTP server) for a Gmail based email account kept appearing "Offline" right after she set it up. Even adding the SMTP server manually in Mail didn't help.
You shouldn’t need to do any of the custom SMTP setup within Mail to get a Gmail based email account working in macOS. Now Gmail accounts should be setup just through "Internet Accounts" in the System Preferences, and the SMTP will be setup automatically.
Removing the account and setting it up again should take care of the issue.
If your SMTP server / Outgoing Mail Account constantly appears "Offline", here's how to fix it:
Close Mail if it's open now.
Click the Apple menu (upper left corner of your screen) > System Preferences > Internet Accounts.
Select the account with the broken outgoing mail server, and then click the minus sign at the bottom.
Reboot your Mac.
Click the Apple menu > System Preferences > Internet Accounts.
Click Google, and sign into your Gmail based account again.
Update 二月 26, 2018:
If you're email is still not working after this, in Mail open the Mail menu > Preferences > Accounts and select your Gmail account. Ensure that the little checkbox for
Enable this account is checked.