Skip to content

office.com Starting TLS handshake and then disconnected #372

@jaccky

Description

@jaccky

Hi,
I've tryed to setup the proxy with Client Credentials Flow to smtp.outlook.com
This is my configurations:


[SMTP-2465]
server_address = smtp.outlook.com
server_port = 587
server_starttls = True
local_address = 127.0.0.1

[[email protected]]
#documentation = *** note: this is an advanced O365 account example; in most cases you want the version above instead ***
token_url = https://login.microsoftonline.com/8f37d23c-8237-447d-8298-a223ad163ff4/oauth2/v2.0/token
oauth2_scope = https://outlook.office.com/SMTP.Send offline_access
oauth2_flow = client_credentials
client_id = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
client_secret = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


And this the log with debug output:

2025-08-01 11:12:59: New incoming connection to SMTP server at 127.0.0.1:2465 (unsecured) proxying smtp.outlook.com:587 (STARTTLS)
2025-08-01 11:12:59: Accepting new connection from 127.0.0.1:53618 to SMTP server at 127.0.0.1:2465 (unsecured) proxying smtp.outlook.com:587 (STARTTLS)
2025-08-01 11:12:59: SMTP (127.0.0.1:53618-{127.0.0.1:2465}-smtp.outlook.com:587) --> [ Client connected ]
2025-08-01 11:13:00: SMTP (127.0.0.1:53618-{127.0.0.1:2465}-smtp.outlook.com:587)     <-- b'220 ZR0P278CA0081.outlook.office365.com Microsoft ESMTP MAIL Service ready at Fri, 1 Aug 2025 09:12:51 +0000 [08DDCF8353751293]\r\n'
2025-08-01 11:13:00: SMTP (127.0.0.1:53618-{127.0.0.1:2465}-smtp.outlook.com:587) <-- b'220 ZR0P278CA0081.outlook.office365.com Microsoft ESMTP MAIL Service ready at Fri, 1 Aug 2025 09:12:51 +0000 [08DDCF8353751293]\r\n'
2025-08-01 11:13:00: SMTP (127.0.0.1:53618-{127.0.0.1:2465}-smtp.outlook.com:587) --> b'EHLO gewissisdb\r\n'
2025-08-01 11:13:00: SMTP (127.0.0.1:53618-{127.0.0.1:2465}-smtp.outlook.com:587)     --> b'EHLO gewissisdb\r\n'
2025-08-01 11:13:00: SMTP (127.0.0.1:53618-{127.0.0.1:2465}-smtp.outlook.com:587)     <-- b'250-ZR0P278CA0081.outlook.office365.com Hello [128.251.157.81]\r\n'
2025-08-01 11:13:00: SMTP (127.0.0.1:53618-{127.0.0.1:2465}-smtp.outlook.com:587)     <-- b'250-SIZE 157286400\r\n'
2025-08-01 11:13:00: SMTP (127.0.0.1:53618-{127.0.0.1:2465}-smtp.outlook.com:587)     <-- b'250-PIPELINING\r\n'
2025-08-01 11:13:00: SMTP (127.0.0.1:53618-{127.0.0.1:2465}-smtp.outlook.com:587)     <-- b'250-DSN\r\n'
2025-08-01 11:13:00: SMTP (127.0.0.1:53618-{127.0.0.1:2465}-smtp.outlook.com:587)     <-- b'250-ENHANCEDSTATUSCODES\r\n'
2025-08-01 11:13:00: SMTP (127.0.0.1:53618-{127.0.0.1:2465}-smtp.outlook.com:587)     <-- b'250-STARTTLS\r\n'
2025-08-01 11:13:00: SMTP (127.0.0.1:53618-{127.0.0.1:2465}-smtp.outlook.com:587)     <-- b'250-8BITMIME\r\n'
2025-08-01 11:13:00: SMTP (127.0.0.1:53618-{127.0.0.1:2465}-smtp.outlook.com:587)     <-- b'250-BINARYMIME\r\n'
2025-08-01 11:13:00: SMTP (127.0.0.1:53618-{127.0.0.1:2465}-smtp.outlook.com:587)     <-- b'250-CHUNKING\r\n'
2025-08-01 11:13:00: SMTP (127.0.0.1:53618-{127.0.0.1:2465}-smtp.outlook.com:587)     <-- b'250 SMTPUTF8\r\n'
2025-08-01 11:13:00: SMTP (127.0.0.1:53618-{127.0.0.1:2465}-smtp.outlook.com:587)     --> b'STARTTLS\r\n'
2025-08-01 11:13:00: SMTP (127.0.0.1:53618-{127.0.0.1:2465}-smtp.outlook.com:587)     <-- b'220 2.0.0 SMTP server ready\r\n'
2025-08-01 11:13:00: SMTP (127.0.0.1:53618-{127.0.0.1:2465}-smtp.outlook.com:587) <-> [ Starting TLS handshake ]
2025-08-01 11:13:00: SMTP (127.0.0.1:53618-{127.0.0.1:2465}-smtp.outlook.com:587) Caught server exception in subclass; client connection closed before data could be sent
2025-08-01 11:13:00: SMTP (127.0.0.1:53618-{127.0.0.1:2465}-smtp.outlook.com:587) <-- [ Server disconnected ]
2025-08-01 11:13:00: SMTP (127.0.0.1:53618-{127.0.0.1:2465}-smtp.outlook.com:587) --> [ Client disconnected ]

As you can see suddendly after TLS handshake, the server disconnects, there is no trace of oauth authentication attempt or else.
Any idea on how to further debug this ?

Many thanks wor your work,
Gian.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions