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
797 stars 86 forks source link

IMAP Connection works only sporadically 365 #200

Closed GGSMK closed 11 months ago

GGSMK commented 11 months ago

I set up the proxy, smtp works without problem, when when trying to receive mails, most of the time i only get server disconnected and client disconnected.

2023-10-12 10:24:13: New incoming connection to IMAP server at ipv4:1993 (unsecured) proxying outlook.office365.com:993 (SSL/TLS) 2023-10-12 10:24:13: Accepting new connection to IMAP server at ipv4:1993 (unsecured) proxying outlook.office365.com:993 (SSL/TLS) via ('ipv4', 53767) 2023-10-12 10:24:34: IMAP (ipv4; ipv4:53767->outlook.office365.com:993) <-- [ Server disconnected ] 2023-10-12 10:24:34: IMAP (ipv4:1993; ipv4:53767->outlook.office365.com:993) --> [ Client disconnected ]

has anyone ever encountered something like this?

my config:

[IMAP-1993] server_address = outlook.office365.com server_port = 993 local_address = 172.21.99.88

[mailauth@iltis.de] permission_url = https://login.microsoftonline.com/xxx/oauth2/v2.0/authorize token_url = https://login.microsoftonline.com/xxx/oauth2/v2.0/token oauth2_scope = https://outlook.office365.com/IMAP.AccessAsUser.All https://outlook.office365.com/POP.AccessAsUser.All https://outlook.office365.com/SMTP.Send offline_access redirect_uri = http://localhost client_id = xxx client_secret = xxx last_activity = 1697097851 token_salt = xxx access_token = xxx access_token_expiry = xxx refresh_token = xxx

[emailproxy] delete_account_token_on_password_error = True encrypt_client_secret_on_first_use = False

simonrob commented 11 months ago

What happens if you try to connect directly to the O365 server via telnet? (i.e. without the proxy)

Do you have the same issue with:

GGSMK commented 11 months ago

i cant connect to the o365 server via telnet,. I used the proxy with same settings in another network with no issues, maybe something is getting blocked in the original network, i´ll investigate.

simonrob commented 11 months ago

I should have been clearer: you'll need to use, e.g.; openssl s_client -crlf -connect localhost:1993 to connect to an encrypted remote server such as O365. But if this doesn't work then the error you get might help debug the proxy issue you're facing.

simonrob commented 11 months ago

Were you able to resolve this?

GGSMK commented 11 months ago

Yes i was. Firewall blocked connections to the imap server.