freescout-help-desk / freescout

FreeScout — Free self-hosted help desk & shared mailbox (Zendesk / Help Scout alternative)
https://freescout.net
GNU Affero General Public License v3.0
2.8k stars 472 forks source link

Freescout IMAP connection error - Error: connection failed #4002

Closed semaf closed 1 month ago

semaf commented 2 months ago

Hey,

I have an issue with the IMAP connection with type of encryption. SMTP is working fine. It is a local connection between two docker containers in same network.

How is the password forwarded? Plain, crypted? Maybe its the TLS version?

Would be about some help.

If using STARTTLS, the log: Apr 26, 15:30:02 Error fetching email Error: connection failed; File: /www/html/overrides/webklex/php-imap/src/Connection/Protocols/ImapProtocol.php (82)

Dovecot log: dovecot-mailcow-1 | dovecot: imap-login: Disconnected: Aborted login by logging out (auth failed, 1 attempts in 3 secs): user=<domain>, method=PLAIN, rip=172.22.1.16, lip=172.22.1.250, TLS, TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)

Using TLS, the log Apr 26, 15:30:02 Error fetching email Error: connection failed; File: /www/html/overrides/webklex/php-imap/src/Connection/Protocols/ImapProtocol.php (82)

Dovecot: dovecot-mailcow-1 | dovecot: imap-login: Disconnected: Too many invalid commands (no auth attempts in 0 secs): user=<>, rip=172.22.1.16, lip=172.22.1.250

Using none encryption: Apr 26, 15:34:04 | Error fetching email | Error: connection setup failed; File: /www/html/vendor/webklex/php-imap/src/Client.php (391)

Dovecot: dovecot-mailcow-1 | dovecot: imap-login: Disconnected: Aborted login by logging out (auth failed, 1 attempts in 0 secs): user=<domain>, rip=172.22.1.16, lip=172.22.1.250

freescout-helpdesk commented 2 months ago

Try to add APP_NEW_FETCHING_LIBRARY=true parameter to the .env file and clear cache.

torrelasley commented 2 months ago

I am receiving the same error:

Error fetching email Error: connection failed; File: /www/html/overrides/webklex/php-imap/src/Connection/Protocols/ImapProtocol.php (82)

This started today after upgrading from 1.8.139 to 1.8.140

I tried adding the APP_NEW_FETCHING_LIBRARY=true parameter and clearing the cache, however the error persists. I did not change any settings before or after upgrading to 1.8.140.

Any other suggestions?

torrelasley commented 2 months ago

I looked over the code changes from 1.8.139 to 1.8.140 and see that APP_NEW_FETCHING_LIBRARY is now defaulted to "true".

freescout-helpdesk commented 2 months ago

@torrelasley What email service are you using? Can you send the screenshot of your Fetching settings.

In the future the old fetching library will be removed, so better to make sure you are able to fetch via the new library.

Try the following: 1) Remove APP_NEW_FETCHING_LIBRARY parameter from the .env file. 2) Clear cache. 3) Go to your mailbox's "Fetching Emails" settings and try different "Encryption" options:

2024-05-18_07-40-50

After changing Encryption or some other Fetching settings DON'T forget to save settings before checking the connection!

torrelasley commented 2 months ago

I followed your steps and removed APP_NEW_FETCHING_LIBRARY and cleared the cache.

Switching to STARTTLS worked for my system!

Note that you must click "Save Settings" after making the change before pushing the "Check Connection" button. At first I thought none of the Encryption settings would work until I realized this.

Unfortunately I didn't take a screenshot before I made the change so I don't know how it was previously set. Thank you for your help!

andyknas commented 2 months ago

Had same issue. Set APP_NEW_FETCHING_LIBRARY=true and it's working again.

freescout-helpdesk commented 2 months ago

@andyknas In the future the old fetching library will be removed, so better to make sure you are able to fetch via the new library.

After changing Encryption or some other Fetching settings DON'T forget to save settings before checking the connection!

bb0x88 commented 2 months ago

I have tried all of the above suggestions and I am still having issues after upgrading to 1.8.140

I have set APP_NEW_FETCHING_LIBRARY and tried all three encryption options

It worked before I did the upgrade using SSL, using zoho IMAP, port 993, imap.zoho.com.au

Error fetching email | Error: connection failed; File: /www/html/overrides/webklex/php-imap/src/Connection/Protocols/ImapProtocol.php (82)

any other things I can try?

freescout-helpdesk commented 2 months ago

After changing Encryption or some other Fetching settings DON'T forget to save settings before checking the connection!

@torrelasley @bb0x88 You can create a temporary email for us to check it and send access and connection details to support@freescout.net

@bb0x88 Are you using personal Zoho mail or Business Zoho mail? We've just checked IMAP connection to the personal Zoho mail and it works fine:

2024-05-23_07-41-35

andyknas commented 1 month ago

I'm out of the office for the FedEx Compatible Envision 2024 Conference thru June 11th. Replies to email will be delayed while away.

If you need urgent assistance please email @.*** and someone from our staff will get back to you during normal business hours.

freescout-help commented 1 month ago

Also try to disable "Validate Certificate" option.

freescout-help commented 1 month ago

In /overrides/webklex/php-imap/src/Connection/Protocols/ImapProtocol.php try to change line 82 to:

throw new ConnectionFailedException('connection failed - '.$e->getMessage(), 0, $e);

Try to connect again and you should see more detailed error message.

jimmie-jam commented 1 month ago

Try to add APP_NEW_FETCHING_LIBRARY=true parameter to the .env file and clear cache.

Where is the .env file?

freescout-help commented 1 month ago

The APP_NEW_FETCHING_LIBRARY=true parameter is outdated and has no effect anymore.

In the latest version of FreeScout fetching errors now became more informative. So in case of any issues see https://github.com/freescout-help-desk/freescout/wiki/Fetching-Emails#troubleshooting-fetching or create a new issue specifying your error.

jimmie-jam commented 1 month ago

The APP_NEW_FETCHING_LIBRARY=true parameter is outdated and has no effect anymore.

In the latest version of FreeScout fetching errors now became more informative. So in case of any issues see https://github.com/freescout-help-desk/freescout/wiki/Fetching-Emails#troubleshooting-fetching or create a new issue specifying your error.

I'd love for any of the troubleshooting guide to have worked, but none of it has. I submitted a new issue, but an admin closed the ticket and referred me here. The error I received is similar to the OP, but the number of my error is 391. I use MS365 for email and SMTP, IMAP, and all other necessary protocols are enabled. No ports are blocked on my server, and other devices I use do allow in and outbound traffic over SMTP, so it is doubtful that my infrastructure is the problem. I cannot find the .env file to enable debugging, and can't seem to fins a thread that point to its location, so I'm kind of hamstrung here. If I could find the .env file, I could enable debugging and check to make sure the file is correct with regard to the fetching library, but alas, it is elusive. If you can point me in the right direction, I'd be grateful.

freescout-help commented 1 month ago

@jimmie-jam For MS365 you need to use modern oAuth IMAP authentication: https://github.com/freescout-help-desk/freescout/wiki/Connect-FreeScout-to-Microsoft-365-Exchange-via-oAuth

jimmie-jam commented 1 month ago

@jimmie-jam For MS365 you need to use modern oAuth IMAP authentication: https://github.com/freescout-help-desk/freescout/wiki/Connect-FreeScout-to-Microsoft-365-Exchange-via-oAuth

I think I have the settings correct for MS365, but because I'm hosting Freescout locally only, the URL I'm using isn't behind an SSL, and therefore can't reach the URL of the app on Entra. Is there a way to do this where I host it on my local network, but not through a proxy? I don't want this accessible via the web. This is just for our company to use to submit technology and building repair issues.