The mail application is corrupted , remove the accounts and once again add Add email accounts in Mail on Mac - Apple Support
If you are using secondary authentication account in which three answers for security questions , date of birth , rescue mail address and its password is added , and iCloud Keychain is set up in Mac , make sure you must have iCloud Keychain verification code in records as it will be required once you add gmail or whatever services used and iCloud account .
( a ) Open system preferences > iCloud > the box for keychain is checked , click on options , click on change security code .
( b ) Click on security code > enter new code in the fields and click on next , you have to enter the new code for the second time and click on next .
In the next window the country code is written , enter your trusted mobile number …….and click on done .
Again enter your Apple ID password to update your account settings and click on ok , hence the code is changed , so write down this code in a safe place .
Note : once the code is generated then remove mail accounts and once again add it , make sure must have correct credentials like Apple ID password , web mail address and its password in your records .