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
Possible Bug in "System.Net.Mail.SmtpClient" when using "UseDefaultCredentials" property #23779
Comments
@mbodm, presumably you're seeing this behavior not just with .NET Core but also with the .NET Framework / desktop? They have the same implementation for this: That said, I agree it's a little confusing, and the docs don't make this clear. |
I think looking at the implementation makes it clear what the problem is: When you set What's confusing is that I think the docs contradict this behavior:
|
Absolutely. The weird part is I'm almost certain there was come kind of opposite behavior where it was necessary to set |
If this is just a documentation issue, feel free to move it to our repo @stephentoub! |
Hey, @svick You are totally right. I just missed that ternary operator part, setting the Credentials back to null. @stephentoub Thx for your answer. I think @jnm2 is right and the class/properties just need a slightly different design. Or at least there should be some short info in the property quick tip, showed with Intellisense. @stephentoub P.S.: Totally aside from the above issue (maybe i will never get the chance again to talk to you ^^): Let me say THX for all the great work you did Stephen, over all the years. All that stuff, especially in the TPL/async/await corner, is fantastic and absolutelly top notch. That level of high quality, of work like yours, is what makes .NET/C# this great platform it is. Great job. So, THX for all of it! |
Thanks for the kind words, @mbodm! 😄 My pleasure. |
OMG, Office 365.... That is no 'documentation' bug, it is super-annoying-lame-code-behaviour-bug-stuff (.NET Framework 4.6.2) |
This bug is still there and it is very dumb and annoying... |
I'd like to work on this, still experiencing this issue |
Hi @nabeelvalley you'd be welcome. There is documentation in this repo that should be sufficient to get you building, editing and debugging. Please let us know if you get stuck. |
Fixed with PR dotnet/corefx#41271 |
Hi,
it seems weird, and after looking a few minutes at your source code, i can not really say why, but it plays a role if the property "UseDefaultCredentials" is set before or after the property "Credentials" of class "SmtpClient" in the Namespace "System.Net.Mail". At least with our mail provider.
Framework: asp.net core
Version: 2.0
Example1:
Example2:
Result:
Example1 works like a charm, while Example2 fails with this Exception:
"System.Net.Mail.SmtpException: 'Mailbox unavailable. The server response was: You are not authenticated. Try to activate SMTP Authentication in your mail'"
There is really no difference, just the switch of that 2 lines of code. We tested this in a clean new asp.net core test project. We simply could reproduce it as often as we want, just by switching this 2 lines. VERY weird ! :)
Our provider for the mail is "Hostpoint" from Swizzerland (see host above in SmtpClient() constructor). Its not possible for me (security reasons) to offer you more information, like users, passwords, etc. so you can test. Sorry.
But maybe the problem exists with other Mail providers like GMail etc. and you can reproduce it there. I didnt tested that. Maybe it is some really special thing with our Mail provider. But it seems definitelly worth for you to look at, i think. Or at least for me, to inform you about that :)
Just want let you know about that strange issue.
Best regards,
Marcel
The text was updated successfully, but these errors were encountered: