From edcb8d3a1e767a07df099a9b90758ea4b92f059e Mon Sep 17 00:00:00 2001 From: Tino Hager Date: Mon, 4 Aug 2025 22:20:52 +0200 Subject: [PATCH] Handle SmtpResponseException in DataCommand Added a catch block for SmtpResponseException in DataCommand to return false when this exception occurs, improving error handling during SMTP data processing. --- Src/SmtpServer/Protocol/DataCommand.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Src/SmtpServer/Protocol/DataCommand.cs b/Src/SmtpServer/Protocol/DataCommand.cs index 0092370..b30ce23 100644 --- a/Src/SmtpServer/Protocol/DataCommand.cs +++ b/Src/SmtpServer/Protocol/DataCommand.cs @@ -58,9 +58,14 @@ await context.Pipe.Input.ReadDotBlockAsync( await context.Pipe.Output.WriteReplyAsync(response, cancellationToken).ConfigureAwait(false); } + catch (SmtpResponseException) + { + return false; + } catch (Exception) { await context.Pipe.Output.WriteReplyAsync(new SmtpResponse(SmtpReplyCode.TransactionFailed), cancellationToken).ConfigureAwait(false); + return false; } return true;