feat: read SMTP recipient limit from relay IMAP metadata

Remove is_chatmail flag, and rely on IMAP metadata
advertising the recipients limit (usually 1000),
falling back to 50 (or fewer in some exceptional cases)
just as before when is_chatmail was false.

Also, server metadata is now keyed per transport,
which in the future eases collecting ICE servers
from all relays (instead of just any first relay).
This commit is contained in:
holger krekel
2026-07-22 20:31:50 +02:00
parent 3a913dfb07
commit 0e4574cd41
10 changed files with 97 additions and 63 deletions
+22 -1
View File
@@ -401,7 +401,28 @@ pub(crate) async fn send_msg_to_smtp(
)
.collect::<Vec<_>>();
let status = smtp_send(context, &recipients_list, body.as_str(), smtp, Some(msg_id)).await;
let chunk_size = context.get_max_smtp_rcpt_to().await?.max(1);
let mut unsent = recipients_list.as_slice();
let status = loop {
let unsent_len = u32::try_from(unsent.len()).context("Too many SMTP recipients")?;
let split_index = usize::try_from(chunk_size.min(unsent_len))
.context("Failed to convert SMTP chunk size")?;
let (chunk, rest) = unsent.split_at(split_index);
let status = smtp_send(context, chunk, body.as_str(), smtp, Some(msg_id)).await;
if !matches!(status, SendResult::Success) || rest.is_empty() {
break status;
}
let rest_str = rest
.iter()
.map(|a| a.as_ref())
.collect::<Vec<_>>()
.join(" ");
context
.sql
.execute("UPDATE smtp SET recipients=? WHERE id=?", (rest_str, rowid))
.await?;
unsent = rest;
};
match status {
SendResult::Retry => {}