If you are using Mac OS catalina 10.15.6 open system preferences > click on Apple ID icon in password and security section see the article https://support.apple.com/en-in/guide/mac-help/mchlf00522d9/mac
It might also prompt to enter only password for existing Apple ID .
Open mail application ( IMAP account ) , you will see bolt icon in front of mails ( it could be gmail account , yahoo ...what ever is used ) , take cursor on top menu bar > mail box > online status > take account online see https://support.apple.com/en-in/guide/mail/mlhlp1105/mac
https://support.apple.com/en-in/guide/mail/mlhlp1032/mac
Or sometimes it will prompt web mail account is offline , it will show cancel or open safari > click on safari , enter the web mail address and password , the OTP code will appear on trusted mobile number , use it and enter on the pop up appeared on the Mac the account will be online .