MailMessage and SmtpClient Error on Windows 8.1

I am facing the following problem on several (not to mention all) Windows 8.x machines:

Running this piece of code:

var message = new MailMessage();
message.From = new MailAddress("sender@foo.bar.com");
message.To.Add(new MailAddress("recipient1@foo.bar.com"));

message.Subject = "This is my subject";
message.Body = "This is the content";

var client = new SmtpClient();
client.Send(message);

Configuration:

<system.net>
    <mailSettings>
        <smtp from="test@foo.com">
            <network host="smtpserver1" port="25" userName="username" password="secret" defaultCredentials="false" />
        </smtp>
    </mailSettings>
</system.net>

against hosted Exchange Server leads to several problems, such as 5.7.1SMTP errors (not authenticated, required base64, etc.)

Running the same code on Windows Server 2008 R2, Windows Server 2012 or Windows 7 works as expected ... Turning the firewall off did not help.

Am I missing the same magic on Windows 8.1 machines?

It doesn't matter if the code works in IIS or in a console application. Setting defaultCredentialsto trueor falsealso does not matter.

Sending mail using the telnet Windows client is also no problem.

Update: Here comes the SMTP WireShark log:

C: EHLO <LOCALMACHINENAME>
S: 250 mail.myhostedexchange.org Hello [<IP>] | 250 SIZE 104857600 | 250 PIPELINING | 250 DSN | 250 ENHANCEDSTATUSCODES | 250 STARTTLS | 250 AUTH GSSAPI NTLM LOGIN | 250 8BITMIME | 250 BINARYMIME | 250 CHUNKING
C: AUTH gssapi <base64 encoded string>
S: 334 <base64 encoded string>
C: base64 username
S: 334 <base64 encoded string>
C: base64 password
S: 535 5.7.3 Authentication unsuccessful

2: Wireshark Windows 8.1 Windows 7 ( ):

Windows 7 - :

C: AUTH gssapi <base64encoded>NTLMSSP + some encoded chars.

Windows 8 - :

C: AUTH gssapi <somehowencodedchars>Token Signing Public Key<somehowencodedchars>WELLKNOWN:PKU2U<somehowencodedchars>SMTPSVCmail.myhostedexchange.org

3:

SendGrid, Windows 8.x. SendGrid Hosted Exchange , SendGrid

250-AUTH=PLAIN LOGIN

Telnet.

4: EnableSSL=true .

+4

Source: https://habr.com/ru/post/1533798/


All Articles