{"record":{"id":"fe8a0abb14ef2f6a","repo":"jstedfast/MailKit","slug":"the-smtp-server-does-not-support-authentication","errorCode":null,"errorMessage":"The SMTP server does not support authentication.","messagePattern":"The SMTP server does not support authentication\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"MailKit/Net/Smtp/SmtpClient.cs","lineNumber":1005,"sourceCode":"\t\t\t\tUpdateCapabilities (response);\n\t\t\t}\n\t\t}\n\n\t\tvoid ValidateArguments (SaslMechanism mechanism)\n\t\t{\n\t\t\tif (mechanism == null)\n\t\t\t\tthrow new ArgumentNullException (nameof (mechanism));\n\n\t\t\tCheckDisposed ();\n\n\t\t\tif (!IsConnected)\n\t\t\t\tthrow new ServiceNotConnectedException (\"The SmtpClient must be connected before you can authenticate.\");\n\n\t\t\tif (IsAuthenticated)\n\t\t\t\tthrow new InvalidOperationException (\"The SmtpClient is already authenticated.\");\n\n\t\t\tif ((capabilities & SmtpCapabilities.Authentication) == 0)\n\t\t\t\tthrow new NotSupportedException (\"The SMTP server does not support authentication.\");\n\n\t\t\tmechanism.ChannelBindingContext = Stream.Stream as IChannelBindingContext;\n\t\t\tmechanism.Uri = new Uri ($\"smtp://{uri.Host}\");\n\t\t}\n\n\t\t/// <summary>\n\t\t/// Authenticate using the specified SASL mechanism.\n\t\t/// </summary>\n\t\t/// <remarks>\n\t\t/// <para>Authenticates using the specified SASL mechanism.</para>\n\t\t/// <para>For a list of available SASL authentication mechanisms supported by the server,\n\t\t/// check the <see cref=\"AuthenticationMechanisms\"/> property after the service has been\n\t\t/// connected.</para>\n\t\t/// </remarks>\n\t\t/// <param name=\"mechanism\">The SASL mechanism.</param>\n\t\t/// <param name=\"cancellationToken\">The cancellation token.</param>\n\t\t/// <exception cref=\"System.ArgumentNullException\">\n\t\t/// <paramref name=\"mechanism\"/> is <see langword=\"null\" />.","sourceCodeStart":987,"sourceCodeEnd":1023,"githubUrl":"https://github.com/jstedfast/MailKit/blob/9d3859a7855e3e17582c07fd01972b8e262bf176/MailKit/Net/Smtp/SmtpClient.cs#L987-L1023","documentation":"SmtpClient.Authenticate throws NotSupportedException when the server's EHLO capabilities do not include SMTP AUTH (the SmtpCapabilities.Authentication bit is unset). The server advertised no authentication extension, so no AUTH command can succeed.","triggerScenarios":"Calling Authenticate on a server whose EHLO response lacks AUTH/ AUTH= mechanisms — e.g. an MX server that is receive-only, port 25 relays, or a misconfigured server that hides AUTH before STARTTLS.","commonSituations":"Connecting to port 25 where AUTH is often disabled; servers that only offer AUTH after switching to TLS (client used SecureSocketOptions.None or SslOnConnect incorrectly, or STARTTLS wasn't negotiated); targeting the wrong host (internal relay vs submission server).","solutions":["Connect to the submission port 587 (or 465) with STARTTLS/SSL so the server advertises AUTH.","Verify capabilities with client.Capabilities after connecting; only call Authenticate when (capabilities & SmtpCapabilities.Authentication) != 0.","Confirm the hostname points to an SMTP submission server, not a plain MX relay."],"exampleFix":"// before\nclient.Connect(\"mail.example.com\", 25, SecureSocketOptions.None);\nclient.Authenticate(user, pass); // NotSupportedException\n\n// after\nclient.Connect(\"smtp.example.com\", 587, SecureSocketOptions.StartTls);\nif ((client.Capabilities & SmtpCapabilities.Authentication) != 0)\n    client.Authenticate(user, pass);","handlingStrategy":"validation","validationCode":"if ((client.Capabilities & SmtpCapabilities.Authentication) == 0)\n    throw new InvalidOperationException(\"SMTP server does not advertise AUTH; check host/port/TLS.\");","typeGuard":null,"tryCatchPattern":"try {\n    client.Authenticate(user, pass);\n} catch (NotSupportedException ex) {\n    // log server capabilities: client.AuthenticationMechanisms\n    throw new MailConfigurationException(\"Server lacks AUTH support\", ex);\n}","preventionTips":["Use submission ports (587 STARTTLS / 465 SSL) for authenticated sending.","Log client.AuthenticationMechanisms after connect to verify server support.","Confirm the hostname is a submission server, not an MX relay."],"tags":["smtp","mailkit","server-capabilities","starttls"],"backgroundTag":"feature-not-enabled","analyzedSha":"9d3859a7855e3e17582c07fd01972b8e262bf176","analyzedAt":"2026-09-15T15:46:11.592Z","contentChangedAt":"2026-09-15T15:46:11.592Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}