0 votes

Greetings,

I am writing to you to get support for a strange case I am experiencing from one of our customers.

After a new PC has been installed, an operator is no longer able to send emails from our software via mail.dll.
We get the "502 Command not implemented" error right after the AUTH LOGIN command

Mail.dll Information: 0 : 27 14:56:24 Connecting to 'smtp.office365.com:587', SSL/TLS: False.
Mail.dll Information: 0 : 27 14:56:24 S: 220 FR4P281CA0293.outlook.office365.com ESMTP Service ready
Mail.dll Information: 0 : 27 14:56:24 C: EHLO [10.10.15.37]
Mail.dll Information: 0 : 27 14:56:24 S: 250-Requested mail action okay, completed
Mail.dll Information: 0 : 27 14:56:24 S: 250-SIZE 20000000
Mail.dll Information: 0 : 27 14:56:24 S: 250-8BITMIME
Mail.dll Information: 0 : 27 14:56:24 S: 250 OK
Mail.dll Information: 0 : 27 14:56:24 C: AUTH LOGIN
Mail.dll Information: 0 : 27 14:56:24 S: 502 Command not implemented

The same version of our software works correctly with the same email from another PC.

Mail.dll Information: 0 : 6 15:14:57 Connecting to 'smtp.office365.com:587', SSL/TLS: False.
Mail.dll Information: 0 : 6 15:14:57 S: 220 FR4P281CA0291.outlook.office365.com Microsoft ESMTP MAIL Service ready at Thu, 11 Jan 2024 14:14:57 +0000
Mail.dll Information: 0 : 6 15:14:57 C: EHLO [10.10.15.32]
Mail.dll Information: 0 : 6 15:14:57 S: 250-FR4P281CA0291.outlook.office365.com Hello [93.57.70.146]
Mail.dll Information: 0 : 6 15:14:57 S: 250-SIZE 157286400
Mail.dll Information: 0 : 6 15:14:57 S: 250-PIPELINING
Mail.dll Information: 0 : 6 15:14:57 S: 250-DSN
Mail.dll Information: 0 : 6 15:14:57 S: 250-ENHANCEDSTATUSCODES
Mail.dll Information: 0 : 6 15:14:57 S: 250-STARTTLS
Mail.dll Information: 0 : 6 15:14:57 S: 250-8BITMIME
Mail.dll Information: 0 : 6 15:14:57 S: 250-BINARYMIME
Mail.dll Information: 0 : 6 15:14:57 S: 250-CHUNKING
Mail.dll Information: 0 : 6 15:14:57 S: 250 SMTPUTF8
Mail.dll Information: 0 : 6 15:14:57 C: STARTTLS
Mail.dll Information: 0 : 6 15:14:57 S: 220 2.0.0 SMTP server ready
Mail.dll Information: 0 : 6 15:14:57 C: EHLO [10.10.15.32]
Mail.dll Information: 0 : 6 15:14:57 S: 250-FR4P281CA0291.outlook.office365.com Hello [93.57.70.146]
Mail.dll Information: 0 : 6 15:14:57 S: 250-SIZE 157286400
Mail.dll Information: 0 : 6 15:14:57 S: 250-PIPELINING
Mail.dll Information: 0 : 6 15:14:57 S: 250-DSN
Mail.dll Information: 0 : 6 15:14:57 S: 250-ENHANCEDSTATUSCODES
Mail.dll Information: 0 : 6 15:14:57 S: 250-AUTH LOGIN XOAUTH2
Mail.dll Information: 0 : 6 15:14:57 S: 250-8BITMIME
Mail.dll Information: 0 : 6 15:14:57 S: 250-BINARYMIME
Mail.dll Information: 0 : 6 15:14:57 S: 250-CHUNKING
Mail.dll Information: 0 : 6 15:14:57 S: 250 SMTPUTF8
Mail.dll Information: 0 : 6 15:14:57 C: AUTH LOGIN
Mail.dll Information: 0 : 6 15:14:57 S: 334 VXNlcm5hbWU6
Mail.dll Information: 0 : 6 15:14:57 C: aW5mb0B1bmlvbi1zcmwuY29t
Mail.dll Information: 0 : 6 15:14:57 S: 334 UGFzc3dvcmQ6
Mail.dll Information: 0 : 6 15:14:57 C: MW5mTUBsVW4kMjIh
Mail.dll Information: 0 : 6 15:14:58 S: 235 2.7.0 Authentication successful
Mail.dll Information: 0 : 6 15:14:58 C: MAIL FROM:info@union-srl.com
Mail.dll Information: 0 : 6 15:14:58 C: RCPT TO:stefanog@compertis.com NOTIFY=SUCCESS,FAILURE
Mail.dll Information: 0 : 6 15:14:58 C: NOOP
Mail.dll Information: 0 : 6 15:14:58 S: 250 2.1.0 Sender OK
Mail.dll Information: 0 : 6 15:14:58 S: 250 2.1.5 Recipient OK
Mail.dll Information: 0 : 6 15:14:58 S: 250 2.0.0 OK
Mail.dll Information: 0 : 6 15:14:58 C: BDAT 324089 LAST
Mail.dll Information: 0 : 6 15:14:58 C (324089 bytes):
Mail.dll Information: 0 : 6 15:14:58 Content-Type: multipart/mixed;
.....
.....

Can you help me and suggest what I can check to understand the origin of the problem?

A thousand thanks

by (351 points)

1 Answer

0 votes

This log shows that this server doesn't support any authentication method nor upgrading connection to TLS:

14:56:24 S: 220 FR4P281CA0293.outlook.office365.com 
                ESMTP Service ready
14:56:24 C: EHLO [10.10.15.37]
14:56:24 S: 250-Requested mail action okay, completed
14:56:24 S: 250-SIZE 20000000
14:56:24 S: 250-8BITMIME
14:56:24 S: 250 OK

It is a very different response from the second one:

15:14:57 S: 220 FR4P281CA0291.outlook.office365.com 
                Microsoft ESMTP MAIL Service ready at 
                Thu, 11 Jan 2024 14:14:57 +0000
15:14:57 C: EHLO [10.10.15.32]
15:14:57 S: 250-FR4P281CA0291.outlook.office365.com 
                Hello [93.57.70.146]
15:14:57 S: 250-SIZE 157286400
15:14:57 S: 250-PIPELINING
15:14:57 S: 250-DSN
15:14:57 S: 250-ENHANCEDSTATUSCODES
15:14:57 S: 250-STARTTLS
15:14:57 S: 250-8BITMIME
15:14:57 S: 250-BINARYMIME
15:14:57 S: 250-CHUNKING
15:14:57 S: 250 SMTPUTF8

Those are completely different servers.

And the first one doesn't look like smtp.office365.com at all. It looks like it's an open relay with absolutely no authentication required.

by (301k points)

Thanks for the feedback,
but the strange thing is that the server should be the same, sending from the two PCs uses the same settings for smtp.office365.com:587

I tried to forcefully start TLS (client.StartTLS()) and on the PC where I encountered the previous error I now receive this:

Mail.dll Information: 0 : 14 09:39:38 Connecting to 'smtp.office365.com:587', SSL/TLS: False.
Mail.dll Information: 0 : 14 09:39:38 S: 220 ZR2P278CA0083.outlook.office365.com ESMTP Service ready
Mail.dll Information: 0 : 14 09:39:38 C: EHLO [10.10.15.37]
Mail.dll Information: 0 : 14 09:39:38 S: 250-Requested mail action okay, completed
Mail.dll Information: 0 : 14 09:39:38 S: 250-SIZE 20000000
Mail.dll Information: 0 : 14 09:39:38 S: 250-8BITMIME
Mail.dll Information: 0 : 14 09:39:38 S: 250 OK
Mail.dll Information: 0 : 14 09:39:38 C: STARTTLS
Mail.dll Information: 0 : 14 09:39:38 S: 503 Bad sequence of commands

Thanks for the support

I can see 3 possible causes:
- AV software in your network, that pretends to be smtp.office365.com
- rouge/corporate DNS that points smtp.office365.com to a different IP
- faulty SMTP server instance inside MS cluster

Check what IP addresses are returned from DNS for 'smtp.office365.com' on both machines.

Thanks for these tips.

We are checking this with the customer's IT department.

As soon as I have any news I will give you feedback.

Thank you

I tried checking via nslookup smtp.office365.com

PC that goes into error:

Name: ZRH-efz.ms-acdc.office.com
Addresses: 2603:1026:c0b:23::2
2603:1026:c0b:800::2
2603:1026:c0b:10::2
2603:1026:c0b:20::2
40.99.217.34
40.99.201.210
52.97.135.50
52.97.201.210
Aliases: smtp.office365.com
outlook.office365.com
ooc-g2.tm-4.office.com
outlook.ms-acdc.office.com

PC sending correctly:

Name: ZRH-efz.ms-acdc.office.com
Addresses: 2603:1026:c0b:40::2
2603:1026:c0b:45::2
2603:1026:c0b:54::2
2603:1026:c0b:20::2
52.98.246.50
52.97.201.226
40.99.201.194
52.97.186.114
Aliases: smtp.office365.com
outlook.office365.com
ooc-g2.tm-4.office.com
outlook.ms-acdc.office.com

The IP addresses are different, but if I try from my office I still find different addresses from PC to PC but sending emails works correctly with the same settings so I struggle to understand if that could be the problem.

Do you have other suggestions?

A thousand thanks

There is nothing wrong with your code.
There is no issue in Mail.dll itself.
Logs show you are using correct port 587.

The problem is this SMTP server:

F42F Connecting to 'smtp.office365.com:587', SSL/TLS: False.
F42F S: 220 FR4P281CA0110.outlook.office365.com ESMTP Service ready
F42F C: EHLO [10.10.15.37]
F42F S: 250-Requested mail action okay, completed
F42F S: 250-SIZE 20000000
F42F S: 250-8BITMIME
F42F S: 250 OK
F42F C: AUTH LOGIN
F42F S: 502 Command not implemented

What this server advertises is, that it does not require authentication at all (that's why it rejects AUTH LOGIN) nor it allows switching to SSL/TLS (no STARTTLS extension present, and STARTTLS is rejected).

You can use ping to get the server IP address, and verify if this is in fact Microsoft IP.
Than you can connect to this IP directly from different network to verify if you are getting the same SMTP conversation.

...