+1 vote

We have recently moved our mail-system to outlook.com, and now I cannot any longer connect to the smtp server for sending mails.

Here's the code I use:

using (Smtp smtp = new Smtp())
{
    smtp.Connect(MailServer, 25);
    smtp.UseBestLogin(MailUser, MailPwd);

and here are the logs:

12:16:25 3.0.16004.1222
12:16:25 Connecting to 'sunair-dk.mail.eo.outlook.com:25', SSL: False.
12:16:25 S: 220 **************
12:16:25 C: EHLO [127.0.0.1]
12:16:25 S: 250-SIZE 157286400
12:16:25 S: 250-PIPELINING
12:16:25 S: 250-DSN
12:16:25 S: 250-ENHANCEDSTATUSCODES
12:16:25 S: 250-XXXXXXXA
12:16:25 S: 250-8BITMIME
12:16:25 S: 250-BINARYMIME
12:16:25 S: 250 XXXXXXXB
12:16:28 C: AUTH LOGIN
12:16:33 S: 504 5.7.4 Unrecognized authentication type
by
retagged by

1 Answer

0 votes
 
Best answer

Your server requires you to turn on SSL/TLS explicitly after the connection.
This is done using StartTLS method (STARTTLS command):

This code is going to work:

smtp.Connect("sunair-dk.mail.eo.outlook.com", 25);
smtp.StartTLS();
smtp.UseBestLogin(MailUser, MailPwd);

Now You may ask why UseBestLogin doesn't do that automatically?
The reason is:

S: 250-ENHANCEDSTATUSCODES
S: 250-XXXXXXXA
S: 250-8BITMIME
S: 250-BINARYMIME
S: 250 XXXXXXXB

When I connect to this server (sunair-dk.mail.eo.outlook.com) I get the following response:

S: 250-ENHANCEDSTATUSCODES
S: 250-STARTTLS   <-this is the indication that StartTLS should be used
S: 250-8BITMIME
S: 250-BINARYMIME
S: 250 CHUNKING

Some software on your machine or network changes the server responses.

For example 250 XXXXXXXB line was 250 CHUNKING,
250-XXXXXXXA was 250-STARTTLS.

I've seen this before and most likely you are running Cisco ASA or Cisco Pix somewhere on your network. It is doing inspection of SMTP traffic and changes this traffic.

You may need to conact your server administrator to be able to connect using STARTTLS:

The problem is typically seen when you use a Cisco Pix or
Cisco ASA firewall when SMTP Packet Inspection
(SMTP and ESMTP Inspection, SMTP Fixup Protocol)
and the STARTTLS command is not allowed in the firewall.

Here's the link on the CISCO site, that explains it in more detail:
http://www.cisco.com/c/en/us/support/docs/security/email-security-appliance/118550-qa-esa-00.html

by (297k points)
...