You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use case: using SmtpClient class to send email to Exchange server
Error: No compatible authentication mechanisms found.. Stack trace: at MailKit.Net.Smtp.SmtpClient.Authenticate(Encoding encoding, ICredentials credentials, CancellationToken cancellationToken)↓↓ at MailKit.MailService.Authenticate(String userName, String password, CancellationToken cancellationToken)
REASON
As visible in the protocol log below, no authentication mechanism is returned in the AUTH line, so parsing by SmtpClient.EhloAsync (bool doAsync, CancellationToken cancellationToken) returns that no authentication mechanism is supported.
Authentication mechanisms are instead returned as part of an X-EXPS line which serves the same purpose in Exchange (see https://technet.microsoft.com/en-us/library/bb123786(v=exchg.65).aspx).
As a workaround I have forced SmtpClient to attempt authentication with NTLM and LOGIN if the server does not respond properly:
if (client.AuthenticationMechanisms.IsEmpty())
{
client.AuthenticationMechanisms.Add("LOGIN");
client.AuthenticationMechanisms.Add("NTLM");
}
However this is less than ideal since the schemes could be a mismatch with what the server actually returned in the X-EXPS line.
Overriding the EhloAsync method is not possible due to visibility issues.
ENHANCEMENT REQUEST
Add a suitable method to allow overriding parsing of response to the Ehlo command to support custom extensions (also X-ANONYMOUSTLS would be interesting to support) or extend response support to parse X-EXPS authentication schemes.
PROTOCOL LOG
Connected to smtp://XXXX.XXXX.com:25/?starttls=always
S: 220 AAAA.XXXX.com Microsoft ESMTP MAIL Service ready at Mon, 18 Dec 2017 13:10:03 +0800
C: EHLO [10.128.2.212]
S: 250-AAAA.XXXX.com Hello [10.128.2.212]
S: 250-SIZE 27262976
S: 250-PIPELINING
S: 250-DSN
S: 250-ENHANCEDSTATUSCODES
S: 250-X-ANONYMOUSTLS
S: 250-AUTH
S: 250-X-EXPS GSSAPI NTLM
S: 250-8BITMIME
S: 250-BINARYMIME
S: 250-CHUNKING
S: 250-XEXCH50
S: 250-XRDST
S: 250 XSHADOW
The text was updated successfully, but these errors were encountered:
Use case: using SmtpClient class to send email to Exchange server
Error: No compatible authentication mechanisms found.. Stack trace: at MailKit.Net.Smtp.SmtpClient.Authenticate(Encoding encoding, ICredentials credentials, CancellationToken cancellationToken)↓↓ at MailKit.MailService.Authenticate(String userName, String password, CancellationToken cancellationToken)
REASON
As visible in the protocol log below, no authentication mechanism is returned in the AUTH line, so parsing by SmtpClient.EhloAsync (bool doAsync, CancellationToken cancellationToken) returns that no authentication mechanism is supported.
Authentication mechanisms are instead returned as part of an X-EXPS line which serves the same purpose in Exchange (see https://technet.microsoft.com/en-us/library/bb123786(v=exchg.65).aspx).
As a workaround I have forced SmtpClient to attempt authentication with NTLM and LOGIN if the server does not respond properly:
if (client.AuthenticationMechanisms.IsEmpty())
{
client.AuthenticationMechanisms.Add("LOGIN");
client.AuthenticationMechanisms.Add("NTLM");
}
However this is less than ideal since the schemes could be a mismatch with what the server actually returned in the X-EXPS line.
Overriding the EhloAsync method is not possible due to visibility issues.
ENHANCEMENT REQUEST
Add a suitable method to allow overriding parsing of response to the Ehlo command to support custom extensions (also X-ANONYMOUSTLS would be interesting to support) or extend response support to parse X-EXPS authentication schemes.
PROTOCOL LOG
Connected to smtp://XXXX.XXXX.com:25/?starttls=always
S: 220 AAAA.XXXX.com Microsoft ESMTP MAIL Service ready at Mon, 18 Dec 2017 13:10:03 +0800
C: EHLO [10.128.2.212]
S: 250-AAAA.XXXX.com Hello [10.128.2.212]
S: 250-SIZE 27262976
S: 250-PIPELINING
S: 250-DSN
S: 250-ENHANCEDSTATUSCODES
S: 250-X-ANONYMOUSTLS
S: 250-AUTH
S: 250-X-EXPS GSSAPI NTLM
S: 250-8BITMIME
S: 250-BINARYMIME
S: 250-CHUNKING
S: 250-XEXCH50
S: 250-XRDST
S: 250 XSHADOW
The text was updated successfully, but these errors were encountered: