diff --git a/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpConnection.cs b/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpConnection.cs index bc2a2bcbfa0c39..a924cdcd980f60 100644 --- a/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpConnection.cs +++ b/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpConnection.cs @@ -628,6 +628,14 @@ private static void SendEHelloCallback(IAsyncResult result) private bool SendHello() { + if (_connection._enableSsl) + { + // We only try HELO command if EHLO was not recognized. Server cannot + // advertise STARTTLS in older HELO command, thus if TLS is required, + // we can fail early. + throw new SmtpException(SR.MailServerDoesNotSupportStartTls); + } + IAsyncResult result = HelloCommand.BeginSend(_connection, _connection._client!._clientDomain, s_sendHelloCallback, this); //if ehello isn't supported, assume basic auth if (result.CompletedSynchronously)