-
-
Notifications
You must be signed in to change notification settings - Fork 828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AuthenticationException being thrown for non-authentication issues? #717
Comments
You could try digging into the InnerException property. That should have the info you are looking for. AuthenticationException -> SaslException -> SmtpCommandException |
Thanks @jstedfast. Will take a look. |
If the InnerException suggestion doesn’t work, let me know and I’ll try to look into making changes to the code so you can get that info. |
It looks like my suggestion won't work now that I am looking at the code. I'll commit a fix shortly. |
FWIW, the nesting goes like this: |
@jstedfast Thanks for following up on this. I had just begun to look at how to get this working. I guess I will need to take the next version with the fix in! So ultimately I can check for password/account specific failures by:
Do you have an ETA on the next release of MailKit? |
Probably not for a few weeks unless a major bug comes to my attention. I try to release every 4-6 weeks or so and I just made a release last week? |
@jstedfast Any chance of a it being quicker? I'm fighting quite a major live issue with this :( |
If I have time this weekend, I'll look into it. In the meantime, donations are welcome :) |
Running into the same problem. I would like some way to figure out what went wrong if authentication fails. InnerException is Null, Message is: "Login failed" @jstedfast could you reopen this issue and look into it please? |
The text "Login failed" likely came from the IMAP, POP3 or SMTP server. You can get a protocol log like this: using (var client = new SmtpClient (new ProtocolLogger ("smtp.log")) Replace "Smtp" with Pop3 or Imap depending on what client you are having this issue with. |
I am using the AuthenticationException to track when I think that the credentials are wrong, assuming that it would only throw when the SMTP Response Code are
SmtpStatusCode.AuthenticationInvalidCredentials
etc. but it seems that in actual fact this exception type can be thrown for any failure - is this correct?Looking at the code all errors are thrown as an AuthenticationException:
MailKit/MailKit/Net/Smtp/SmtpClient.cs
Lines 733 to 738 in 6d21ecd
The description suggests otherwise:
MailKit/MailKit/Net/Smtp/SmtpClient.cs
Lines 636 to 638 in 6d21ecd
I believe that I am getting AuthenticationExceptions with messages such as:
Which is problematic as the AuthenticationException does not have an StatusCode which I could inspect for more details.
How should I be detecting true failures of credentials?
The text was updated successfully, but these errors were encountered: