Skip to content

Commit

Permalink
Update SMTP status codes (#1109)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdecimus committed Jan 20, 2025
1 parent 5e5771e commit 4eca415
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion crates/jmap/src/api/form.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl FormHandler for Server {
if let Some(domain) = from_email.rsplit_once('@').and_then(|(local, domain)| {
if !local.is_empty()
&& domain.contains('.')
&& psl::suffix(domain.as_bytes()).is_some()
&& psl::domain(domain.as_bytes()).is_some_and(|d| d.suffix().typ().is_some())
{
Some(domain)
} else {
Expand Down
2 changes: 1 addition & 1 deletion crates/smtp/src/inbound/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ impl<T: SessionStream> Session<T> {
SpanId = self.data.session_id,
);

self.write(b"421 4.3.0 Too many authentication errors, disconnecting.\r\n")
self.write(b"455 4.3.0 Too many authentication errors, disconnecting.\r\n")
.await?;
Err(())
}
Expand Down
2 changes: 1 addition & 1 deletion crates/smtp/src/inbound/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ impl<T: SessionStream> Session<T> {
Limit = self.data.messages_sent
);

self.write(b"451 4.4.5 Maximum number of messages per session exceeded.\r\n")
self.write(b"452 4.4.5 Maximum number of messages per session exceeded.\r\n")
.await?;
Ok(false)
}
Expand Down
2 changes: 1 addition & 1 deletion crates/smtp/src/inbound/mail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ impl<T: SessionStream> Session<T> {
);

self.data.mail_from = None;
self.write(b"451 4.4.5 Rate limit exceeded, try again later.\r\n")
self.write(b"452 4.4.5 Rate limit exceeded, try again later.\r\n")
.await
}
}
Expand Down
8 changes: 4 additions & 4 deletions crates/smtp/src/inbound/rcpt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl<T: SessionStream> Session<T> {
SpanId = self.data.session_id,
Limit = self.params.rcpt_max,
);
return self.write(b"451 4.5.3 Too many recipients.\r\n").await;
return self.write(b"455 4.5.3 Too many recipients.\r\n").await;
}

// Verify parameters
Expand Down Expand Up @@ -347,7 +347,7 @@ impl<T: SessionStream> Session<T> {
return self
.write(
concat!(
"422 4.2.2 Greylisted, please try ",
"452 4.2.2 Greylisted, please try ",
"again in a few moments.\r\n"
)
.as_bytes(),
Expand Down Expand Up @@ -385,7 +385,7 @@ impl<T: SessionStream> Session<T> {

self.data.rcpt_to.pop();
return self
.write(b"451 4.4.5 Rate limit exceeded, try again later.\r\n")
.write(b"452 4.4.5 Rate limit exceeded, try again later.\r\n")
.await;
}

Expand Down Expand Up @@ -448,7 +448,7 @@ impl<T: SessionStream> Session<T> {
if !has_too_many_errors {
self.write(response).await
} else {
self.write(b"421 4.3.0 Too many errors, disconnecting.\r\n")
self.write(b"451 4.3.0 Too many errors, disconnecting.\r\n")
.await?;
Err(())
}
Expand Down
6 changes: 3 additions & 3 deletions crates/smtp/src/inbound/spawn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ impl<T: SessionStream> Session<T> {
}
} else if bytes_read > self.data.bytes_left {
self
.write(format!("451 4.7.28 {} Session exceeded transfer quota.\r\n", self.hostname).as_bytes())
.write(format!("452 4.7.28 {} Session exceeded transfer quota.\r\n", self.hostname).as_bytes())
.await
.ok();

Expand All @@ -181,7 +181,7 @@ impl<T: SessionStream> Session<T> {
break;
} else {
self
.write(format!("453 4.3.2 {} Session open for too long.\r\n", self.hostname).as_bytes())
.write(format!("421 4.3.2 {} Session open for too long.\r\n", self.hostname).as_bytes())
.await
.ok();

Expand Down Expand Up @@ -246,7 +246,7 @@ impl<T: SessionStream> Session<T> {
Reason = "Server shutting down",
CausedBy = trc::location!()
);
self.write(b"421 4.3.0 Server shutting down.\r\n").await.ok();
self.write(format!("421 4.3.0 {} Server shutting down.\r\n", self.hostname).as_bytes()).await.ok();
break;
}
};
Expand Down

0 comments on commit 4eca415

Please sign in to comment.