simonrob / email-oauth2-proxy

An IMAP/POP/SMTP proxy that transparently adds OAuth 2.0 authentication for email clients that don't support this method.
Apache License 2.0
785 stars 84 forks source link

Office365: 500 5.3.3 Unrecognized command 'unknown' #234

Closed niklasfink closed 5 months ago

niklasfink commented 5 months ago

Hi @simonrob, these 500 5.3.3 Unrecognized command 'unknown' are coming regularly. This is a full log output when my printer unsuccessfully wants to send an email:

2024-03-03 19:15:01: SMTP ([internalip]:36607-{[::ffff:internalip]:25}-outlook.office365.com:587) --> [ Client connected ]
2024-03-03 19:15:01: SMTP ([internalip]:36607-{[::ffff:internalip]:25}-outlook.office365.com:587)     <-- b'220 xx.outlook.office365.com Microsoft ESMTP MAIL Service ready at Sun, 3 Mar 2024 19:15:00 +0000\r\n'
2024-03-03 19:15:01: SMTP ([internalip]:36607-{[::ffff:internalip]:25}-outlook.office365.com:587) <-- b'220 xx.outlook.office365.com Microsoft ESMTP MAIL Service ready at Sun, 3 Mar 2024 19:15:00 +0000\r\n'
2024-03-03 19:15:01: SMTP ([internalip]:36607-{[::ffff:internalip]:25}-outlook.office365.com:587) --> b'QUIT\n!\x11\x00\x0c\xac\x12\x00\x01\xac\x12\x00\x08\xd4p\x00\x19EHLO [localip]\r\n'
2024-03-03 19:15:01: SMTP ([internalip]:36607-{[::ffff:internalip]:25}-outlook.office365.com:587)     --> b'QUIT\n!\x11\x00\x0c\xac\x12\x00\x01\xac\x12\x00\x08\xd4p\x00\x19EHLO [localip]\r\n'
2024-03-03 19:15:06: SMTP ([internalip]:36607-{[::ffff:internalip]:25}-outlook.office365.com:587)     <-- b"500 5.3.3 Unrecognized command 'unknown' [xx.xx.PROD.OUTLOOK.COM 2024-03-03T19:15:06.603Z xx]\r\n"
2024-03-03 19:15:06: SMTP ([internalip]:36607-{[::ffff:internalip]:25}-outlook.office365.com:587) <-- b"500 5.3.3 Unrecognized command 'unknown' [xx.xx.PROD.OUTLOOK.COM 2024-03-03T19:15:06.603Z xx]\r\n"
2024-03-03 19:15:06: SMTP ([internalip]:36607-{[::ffff:internalip]:25}-outlook.office365.com:587) --> b'HELO [localip]\r\n'
2024-03-03 19:15:06: SMTP ([internalip]:36607-{[::ffff:internalip]:25}-outlook.office365.com:587)     --> b'HELO [localip]\r\n'
2024-03-03 19:15:11: 2024-03-03 19:15:11,612: SMTP ([internalip]:36607-{[::ffff:internalip]:25}-outlook.office365.com:587)     <-- b"500 5.3.3 Unrecognized command 'unknown' [xx.xx.PROD.OUTLOOK.COM 2024-03-03T19:15:11.603Z xx]\r\n"
2024-03-03 19:15:16,612: SMTP ([internalip]:36607-{[::ffff:internalip]:25}-outlook.office365.com:587)     <-- b"500 5.3.3 Unrecognized command '<redacted>' [xx.xx.PROD.OUTLOOK.COM 2024-03-03T19:15:16.603Z xx]\r\n"
2024-03-03 19:15:21,612: SMTP ([internalip]:36607-{[::ffff:internalip]:25}-outlook.office365.com:587)     <-- b"500 5.3.3 Unrecognized command '<redacted>' [xx.xx.PROD.OUTLOOK.COM 2024-03-03T19:15:21.603Z xx]\r\n"
2024-03-03 19:15:21,630: SMTP ([internalip]:36607-{[::ffff:internalip]:25}-outlook.office365.com:587)     <-- b'250 xx.outlook.office365.com Hello [publicip]\r\n'
2024-03-03 19:15:21,630: SMTP ([internalip]:36607-{[::ffff:internalip]:25}-outlook.office365.com:587)     --> b'STARTTLS\r\n'
2024-03-03 19:15:21,648: SMTP ([internalip]:36607-{[::ffff:internalip]:25}-outlook.office365.com:587)     <-- b'220 2.0.0 SMTP server ready\r\n'
2024-03-03 19:15:21,668: SMTP ([internalip]:36607-{[::ffff:internalip]:25}-outlook.office365.com:587) <-> [ Starting TLS handshake ]
2024-03-03 19:15:21,669: SMTP ([internalip]:36607-{[::ffff:internalip]:25}-outlook.office365.com:587) [ Successfully negotiated SMTP STARTTLS connection - re-sending greeting ]
2024-03-03 19:15:21,669: SMTP ([internalip]:36607-{[::ffff:internalip]:25}-outlook.office365.com:587)     --> b'HELO [localip]\r\n'
2024-03-03 19:15:21,716: SMTP ([internalip]:36607-{[::ffff:internalip]:25}-outlook.office365.com:587) <-> [ TLSv1.3 handshake complete ]
2024-03-03 19:15:21,752: SMTP ([internalip]:36607-{[::ffff:internalip]:25}-outlook.office365.com:587)     <-- b'250 xx.outlook.office365.com Hello [publicip]\r\n'
2024-03-03 19:15:21,753: SMTP ([internalip]:36607-{[::ffff:internalip]:25}-outlook.office365.com:587) <-- b'250 xx.outlook.office365.com Hello [publicip]\r\n'
2024-03-03 19:15:21,754: SMTP ([internalip]:36607-{[::ffff:internalip]:25}-outlook.office365.com:587) --> b'MAIL FROM:<mail@mydomain.com>\r\n'
2024-03-03 19:15:21,754: SMTP ([internalip]:36607-{[::ffff:internalip]:25}-outlook.office365.com:587)     --> b'MAIL FROM:<mail@mydomain.com>\r\n'
2024-03-03 19:15:26,783: SMTP ([internalip]:36607-{[::ffff:internalip]:25}-outlook.office365.com:587)     <-- b'530 5.7.57 Client not authenticated to send mail. [xx.xx.PROD.OUTLOOK.COM 2024-03-03T19:15:26.774Z xx]\r\n'
2024-03-03 19:15:26,783: SMTP ([internalip]:36607-{[::ffff:internalip]:25}-outlook.office365.com:587) <-- b'530 5.7.57 Client not authenticated to send mail. [xx.xx.PROD.OUTLOOK.COM 2024-03-03T19:15:26.774Z xx]\r\n'
2024-03-03 19:15:26,784: SMTP ([internalip]:36607-{[::ffff:internalip]:25}-outlook.office365.com:587) <-- [ Server disconnected ]
2024-03-03 19:15:26,784: SMTP ([internalip]:36607-{[::ffff:internalip]:25}-outlook.office365.com:587) --> [ Client disconnected ]

Config:

[SMTP-25]
server_address = outlook.office365.com
server_port = 587
starttls = True

[mailaddress]
permission_url = https://login.microsoftonline.com/tenantid/oauth2/v2.0/authorize
token_url = https://login.microsoftonline.com/tenantid/oauth2/v2.0/token
oauth2_scope = https://outlook.office365.com/SMTP.Send offline_access
redirect_uri = https://emailproxy.local
redirect_listen_address = http://emailproxy:80
client_id = ...
client_secret = ...
simonrob commented 5 months ago

See #232 for discussion about this.