I have configured properly with my Gmail account details in the System Emails Accounts screen and it is NOT working . The same details I have configured in other instance of same version observed it is working fine.
Also verified by unpublishing the package still NOT working getting the same error. Please find the screenshots for reference. Can you please provide your thoughts on this?
Best answer by Ali Jani
Somehow the network socket is getting closed prematurely. Are you sure you have set outgoing server to TLS and port 587 and not port 25? Perhaps connection is being closed form mail server side.
If you are sure you have setting setup right and they are exact same with TLS on both instances and one works and the other does not, try restarting IIS and assigning an perhaps assigning a separate app pool to the instance having the issue. If this does not fix it, then some other other underlying network/security configuration trouble shooting probably needed.
Also try another mail client on the server to make sure Mail works from another client. see https://www.neroblanco.co.uk/2015/05/sending-tls-mail-to-exchange-from-the-command-line/ for example on how to use command line to test.