diff --git a/crates/smtp/src/inbound/ehlo.rs b/crates/smtp/src/inbound/ehlo.rs index fa5ab299..71bc1680 100644 --- a/crates/smtp/src/inbound/ehlo.rs +++ b/crates/smtp/src/inbound/ehlo.rs @@ -29,7 +29,7 @@ use smtp_proto::*; use utils::listener::SessionStream; impl Session { - pub async fn handle_ehlo(&mut self, domain: String) -> Result<(), ()> { + pub async fn handle_ehlo(&mut self, domain: String, is_extended: bool) -> Result<(), ()> { // Set EHLO domain if domain != self.data.helo_domain { @@ -115,6 +115,12 @@ impl Session { self.reset(); } + if !is_extended { + return self + .write(format!("250 {} says hello\r\n", self.instance.hostname).as_bytes()) + .await; + } + let mut response = EhloResponse::new(self.instance.hostname.as_str()); response.capabilities = EXT_ENHANCED_STATUS_CODES | EXT_8BIT_MIME | EXT_BINARY_MIME | EXT_SMTP_UTF8; diff --git a/crates/smtp/src/inbound/session.rs b/crates/smtp/src/inbound/session.rs index b76d6252..c6e604b2 100644 --- a/crates/smtp/src/inbound/session.rs +++ b/crates/smtp/src/inbound/session.rs @@ -56,7 +56,7 @@ impl Session { } Request::Ehlo { host } => { if self.instance.protocol == ServerProtocol::Smtp { - self.handle_ehlo(host).await?; + self.handle_ehlo(host, true).await?; } else { self.write(b"500 5.5.1 Invalid command.\r\n").await?; } @@ -172,22 +172,15 @@ impl Session { .await?; } Request::Helo { host } => { - if self.instance.protocol == ServerProtocol::Smtp - && self.data.helo_domain.is_empty() - { - self.data.helo_domain = host; - self.write( - format!("250 {} says hello\r\n", self.instance.hostname) - .as_bytes(), - ) - .await?; + if self.instance.protocol == ServerProtocol::Smtp { + self.handle_ehlo(host, false).await?; } else { - self.write(b"503 5.5.1 Invalid command.\r\n").await?; + self.write(b"500 5.5.1 Invalid command.\r\n").await?; } } Request::Lhlo { host } => { if self.instance.protocol == ServerProtocol::Lmtp { - self.handle_ehlo(host).await?; + self.handle_ehlo(host, true).await?; } else { self.write(b"502 5.5.1 Invalid command.\r\n").await?; }