diff --git a/FAQ.md b/FAQ.md
index ebe92ec7df..e27059fbd6 100644
--- a/FAQ.md
+++ b/FAQ.md
@@ -1416,13 +1416,16 @@ consider switching to a modern provider which supports push messages (IMAP IDLE)
If your device has an [AMOLED](https://en.wikipedia.org/wiki/AMOLED) screen,
you can save battery usage while viewing messages by switching to the black theme.
-By default auto optimize in the receive settings is enabled,
-which will switch an account to periodically checking for new messages when the email server:
+If auto optimize in the receive settings is enabled,
+an account will automatically be switched to periodically checking for new messages when the email server:
* Says '*Still here*' within 3 minutes
* The email server does not support push messages
* The keep-alive interval is lower than 12 minutes
+In addition, the trash and spam folders will be automatically set to checking for new messages
+after three successive [too many simultaneous connections](#user-content-faq23) errors.
+
diff --git a/app/src/main/java/eu/faircode/email/DaoFolder.java b/app/src/main/java/eu/faircode/email/DaoFolder.java
index d8c1b3bc37..873200a65a 100644
--- a/app/src/main/java/eu/faircode/email/DaoFolder.java
+++ b/app/src/main/java/eu/faircode/email/DaoFolder.java
@@ -326,6 +326,9 @@ public interface DaoFolder {
@Query("UPDATE folder SET tbd = 1 WHERE id = :id")
int setFolderTbd(long id);
+ @Query("UPDATE folder SET poll = :poll, poll_count = 1 WHERE id = :id")
+ int setFolderPoll(long id, boolean poll);
+
@Query("UPDATE folder SET poll_count = :count WHERE id = :id")
int setFolderPollCount(long id, int count);
diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java
index 2a7a42c0f2..52f3dd36dd 100644
--- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java
+++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java
@@ -1578,6 +1578,21 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
" last connected: " + new Date(account.last_connected));
if (errors >= FAST_ERROR_COUNT)
state.setBackoff(FAST_ERROR_BACKOFF * 60);
+
+ boolean auto_optimize = prefs.getBoolean("auto_optimize", false);
+ if (auto_optimize) {
+ Throwable e = ex;
+ while (e != null) {
+ if (ConnectionHelper.isMaxConnections(e.getMessage())) {
+ for (String ft : new String[]{EntityFolder.TRASH, EntityFolder.JUNK}) {
+ EntityFolder f = db.folder().getFolderByType(account.id, ft);
+ if (f != null)
+ db.folder().setFolderPoll(f.id, true);
+ }
+ }
+ e = e.getCause();
+ }
+ }
}
// Report account connection error