mirror of
https://github.com/stalwartlabs/mail-server.git
synced 2024-09-20 07:16:18 +08:00
SMTP HELO command
This commit is contained in:
parent
3d7b9b0334
commit
66669545ff
|
@ -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;
|
||||
|
|
|
@ -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?;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue