The issue was not in the mail server. It was actually due to a change in the policy of authenticating less secure apps by google as mentioned below.
To help keep your account secure, from May 30, 2022, Google no longer supports the use of third-party apps or devices which ask you to sign in to your Google Account using only your username and password.
Important: This deadline does not apply to Google Workspace or Google Cloud Identity customers. The enforcement date for these customers will be announced on the Workspace blog at a later date.
In order to authenticate less secure apps, we can use an app password.
An App Password is a 16-digit passcode that gives a less secure app or device permission to access your Google Account. App Passwords can only be used with accounts that have 2-Step Verification turned on.
May be can also explore using Gmail API for mail instead of using SMTP
The issue was not in the mail server. It was actually due to a change in the policy of authenticating less secure apps by google as mentioned below.
In order to authenticate less secure apps, we can use an app password.
May be can also explore using Gmail API for mail instead of using SMTP