Skip to content

Commit 16550dd

Browse files
Merge commit 'e1f19886fe3354963a4a790c896b3f99689fd7a5' into internal-merge-9.0-2025-10-14-1155
2 parents 0d09ce7 + e1f1988 commit 16550dd

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpConnection.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,14 @@ private static void SendEHelloCallback(IAsyncResult result)
628628

629629
private bool SendHello()
630630
{
631+
if (_connection._enableSsl)
632+
{
633+
// We only try HELO command if EHLO was not recognized. Server cannot
634+
// advertise STARTTLS in older HELO command, thus if TLS is required,
635+
// we can fail early.
636+
throw new SmtpException(SR.MailServerDoesNotSupportStartTls);
637+
}
638+
631639
IAsyncResult result = HelloCommand.BeginSend(_connection, _connection._client!._clientDomain, s_sendHelloCallback, this);
632640
//if ehello isn't supported, assume basic auth
633641
if (result.CompletedSynchronously)

0 commit comments

Comments
 (0)