fix(smtp): reject journaling attempts to non-local accounts

This commit is contained in:
rustmailer
2026-06-11 09:22:57 +08:00
parent 6f572b15ae
commit 2f5de48c6a
+13
View File
@@ -21,6 +21,7 @@ use std::net::SocketAddr;
use std::time::Duration; use std::time::Duration;
use base64::{prelude::BASE64_STANDARD, Engine as _}; use base64::{prelude::BASE64_STANDARD, Engine as _};
use bichon_core::account::migration::AccountType;
use bichon_core::cache::imap::mailbox::{Attribute, AttributeEnum}; use bichon_core::cache::imap::mailbox::{Attribute, AttributeEnum};
use bichon_core::common::signal::SIGNAL_MANAGER; use bichon_core::common::signal::SIGNAL_MANAGER;
use bichon_core::envelope::extractor::extract_envelope_from_smtp; use bichon_core::envelope::extractor::extract_envelope_from_smtp;
@@ -429,10 +430,22 @@ where
} }
if is_allowed { if is_allowed {
if !matches!(account.account_type, AccountType::NoSync) {
tracing::warn!(
"SMTP: Rejected journaling attempt to IMAP account <{}>",
addr
);
let err = format!(
"550 5.7.1 <{}>: Not a Bichon local account, journaling is not supported\r\n",
account.email
);
stream.write_all(err.as_bytes()).await?;
} else {
session.rcpt_to.push(account); session.rcpt_to.push(account);
stream.write_all(b"250 OK\r\n").await?; stream.write_all(b"250 OK\r\n").await?;
} }
} }
}
Ok(None) => { Ok(None) => {
let err = format!("550 5.1.1 <{}>: Bichon account not found\r\n", addr); let err = format!("550 5.1.1 <{}>: Bichon account not found\r\n", addr);
stream.write_all(err.as_bytes()).await?; stream.write_all(err.as_bytes()).await?;