From 3896044f368b1e8bd222bf249ef52ea37d213634 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Tue, 12 May 2026 12:13:00 +0200 Subject: [PATCH] fix: return HTTP 200 because madmail expects it, and make sure https is immediately retried when SMTP fails (#153) --- filtermail/src/http_server.rs | 2 +- filtermail/src/transport.rs | 18 ++++++++---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/filtermail/src/http_server.rs b/filtermail/src/http_server.rs index 1e943ddf..513de58b 100644 --- a/filtermail/src/http_server.rs +++ b/filtermail/src/http_server.rs @@ -137,7 +137,7 @@ impl Service> for MxDelivService match handler.handle_data(&mut envelope).await { Ok(response) => Ok(Response::builder() - .status(201) + .status(200) .body(Full::new(Bytes::from(response)).boxed())?), Err(e) => Ok(Response::builder() .status(400) diff --git a/filtermail/src/transport.rs b/filtermail/src/transport.rs index a6f0fc40..ce3a17f9 100644 --- a/filtermail/src/transport.rs +++ b/filtermail/src/transport.rs @@ -247,16 +247,14 @@ impl TransportHandler { // We only want to try other MX hosts if we encounter a problem // related to connection. // (So we don't spam other servers if the message is actually rejected.) - crate::error::Error::Io(io_err) => { - log::warn!("I/O error relaying to mail server {mx_host}: {io_err}"); - continue 'try_relay; - } - crate::error::Error::ConnectionFailed(_) => { - log::warn!("Failed to connect to mail server {mx_host}: {error}"); - continue 'try_relay; - } - crate::error::Error::Tls(tls_err) => { - log::warn!("TLS error relaying to mail server {mx_host}: {tls_err}"); + crate::error::Error::Io(_) + | crate::error::Error::ConnectionFailed(_) + | crate::error::Error::Tls(_) => { + // Make sure we quickly retry HTTP if SMTP failed to connect + mxdeliv_unsupported_hosts.remove(&mx_host).await; + log::warn!( + "Connection error relaying to mail server {mx_host}: {error}" + ); continue 'try_relay; } _ => {