diff --git a/src/imap/client.rs b/src/imap/client.rs index 21a84d46af..7c819ed50d 100644 --- a/src/imap/client.rs +++ b/src/imap/client.rs @@ -206,11 +206,14 @@ impl Client { connection_attempt_set.spawn(fut); } - // Start second connection attempt 300 ms after the first. - delay_set.spawn(tokio::time::sleep(Duration::from_millis(300))); - - // Start third connection attempt if we have not managed to connect in 10 seconds. - delay_set.spawn(tokio::time::sleep(Duration::from_secs(10))); + // Start second, third and fourth connection attempt 300 ms, 10 s and 15 s after the first. + for delay in [ + Duration::from_millis(300), + Duration::from_secs(10), + Duration::from_secs(15), + ] { + delay_set.spawn(tokio::time::sleep(delay)); + } let mut first_error = None; loop { diff --git a/src/smtp/connect.rs b/src/smtp/connect.rs index a8e940df53..7082d87f27 100644 --- a/src/smtp/connect.rs +++ b/src/smtp/connect.rs @@ -177,11 +177,14 @@ async fn connect_stream( connection_attempt_set.spawn(fut); } - // Start second connection attempt 300 ms after the first. - delay_set.spawn(tokio::time::sleep(Duration::from_millis(300))); - - // Start third connection attempt if we have not managed to connect in 10 seconds. - delay_set.spawn(tokio::time::sleep(Duration::from_secs(10))); + // Start second, third and fourth connection attempt 300 ms, 10 s and 15 s after the first. + for delay in [ + Duration::from_millis(300), + Duration::from_secs(10), + Duration::from_secs(15), + ] { + delay_set.spawn(tokio::time::sleep(delay)); + } let mut first_error = None; loop {