summaryrefslogtreecommitdiff
path: root/crates/smtp
diff options
context:
space:
mode:
authormdecimus <mauro@stalw.art>2024-02-10 16:25:34 +0100
committermdecimus <mauro@stalw.art>2024-02-10 16:25:34 +0100
commit66669545ff43c2bd4a53a0cbd50c6a53b9ced59b (patch)
treec4a636b3f4d6765a2b95f8d42edd6b1cffd497e5 /crates/smtp
parent3d7b9b0334c23f60f7699b56c7bdbdb5c18ef425 (diff)
SMTP HELO command
Diffstat (limited to 'crates/smtp')
-rw-r--r--crates/smtp/src/inbound/ehlo.rs8
-rw-r--r--crates/smtp/src/inbound/session.rs17
2 files changed, 12 insertions, 13 deletions
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<T: SessionStream> Session<T> {
- 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<T: SessionStream> Session<T> {
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<T: SessionStream> Session<T> {
}
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<T: SessionStream> Session<T> {
.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?;
}