You can delete the accounts and once again configure , the account when set up will go to default settings and when configured the mails will again start syncing .
- Take back up of all mails in V 7 folder
Click on finder take cursor on top menu bar > Go and hold option key click on > library > select mail folder > right click on mail folder there itself > click on copy mail > right click on the desktop > click on paste item .
Entire mails are copied to V 7 folder and will get saved on the desktop .
See the thread https://discussions.apple.com/thread/8517158
If you don't remember the code , overwrite it will be required to set up gmail account , when mail accounts are once again configured .
Then delete the accounts Add or remove email accounts in Mail on Mac - Apple Support
Note : saving mails in V7 folder is just for security , not a single mail will be lost if any thing goes wrong , applicable for POP / IMAP accounts .