Why SmtpClient.UseDefaultCredentials is ignored?
I'm trying to send e-mails through a domain SMTP server which uses Integrated Windows Authentication. When explicitly specifying the credentials, everything works fine:

    using (var client = new SmtpClient("<Server>"))
    {
        client.Credentials = new NetworkCredential("<User name>", "<Password>");
        client.EnableSsl = true;
        client.Send(...);
    }

SMTP server logs show EHLO, STARTTLS, STARTTLS and EHLO, then AUTH, MAIL, etc.

When, on the other hand, default credentials are used:

    using (var client = new SmtpClient("<Server>"))
    {
        client.UseDefaultCredentials = true;
        client.EnableSsl = true;
        client.Send(...);
    }

- the `SmtpException` is thrown, with a message “Failure sending mail.”;

- the inner `IOException` message is: “Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.”, and

- the inner-inner `SocketException` is: “An existing connection was forcibly closed by the remote host”.

SMTP server logs show EHLO, STARTTLS, STARTTLS and EHLO, then nothing.

Given that:

- [according to the documentation][1], `SmtpClient.UseDefaultCredentials` “[g]ets or sets a Boolean value that controls whether the DefaultCredentials are sent with requests”, that

- “For a client-side application, [[`CredentialCache.DefaultCredentials`][2]] are usually the Windows credentials (user name, password, and domain) of the user running the application”, and that

- the tested code is a Windows Forms client-side application running from the same account whose credentials were specified in the first sample above,

why the second sample fails, while the first one works?


  [1]: http://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient.usedefaultcredentials
  [2]: http://msdn.microsoft.com/en-us/library/system.net.credentialcache.defaultcredentials.aspx
Why SmtpClient.UseDefaultCredentials is ignored?
===

I'm trying to send e-mails through a domain SMTP server which uses Integrated Windows Authentication. When explicitly specifying the credentials, everything works fine:

    using (var client = new SmtpClient("<Server>"))
    {
        client.Credentials = new NetworkCredential("<User name>", "<Password>");
        client.EnableSsl = true;
        client.Send(...);
    }

SMTP server logs show EHLO, STARTTLS, STARTTLS and EHLO, then AUTH, MAIL, etc.

When, on the other hand, default credentials are used:

    using (var client = new SmtpClient("<Server>"))
    {
        client.UseDefaultCredentials = true;
        client.EnableSsl = true;
        client.Send(...);
    }

- the `SmtpException` is thrown, with a message “Failure sending mail.”;

- the inner `IOException` message is: “Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.”, and

- the inner-inner `SocketException` is: “An existing connection was forcibly closed by the remote host”.

SMTP server logs show EHLO, STARTTLS, STARTTLS and EHLO, then nothing.

Given that:

- [according to the documentation][1], `SmtpClient.UseDefaultCredentials` “[g]ets or sets a Boolean value that controls whether the DefaultCredentials are sent with requests”, that

- “For a client-side application, [[`CredentialCache.DefaultCredentials`][2]] are usually the Windows credentials (user name, password, and domain) of the user running the application”, and that

- the tested code is a Windows Forms client-side application running from the same account whose credentials were specified in the first sample above,

why the second sample fails, while the first one works?


  [1]: http://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient.usedefaultcredentials
  [2]: http://msdn.microsoft.com/en-us/library/system.net.credentialcache.defaultcredentials.aspx