From c075a8cd8bb116dc1b8ecae9880a70656d362714 Mon Sep 17 00:00:00 2001 From: Laurent Meunier Date: Sun, 31 Mar 2024 12:35:04 +0200 Subject: [PATCH] Also check smtputf8 for submitted messages or when in pedantic mode --- smtpserver/server.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/smtpserver/server.go b/smtpserver/server.go index 8c7e837..fb1f5e3 100644 --- a/smtpserver/server.go +++ b/smtpserver/server.go @@ -1804,9 +1804,8 @@ func (c *conn) cmdData(p *parser) { } // Now that we have all the whole message (envelope + data), we can check if the SMTPUTF8 extension is required. - // The check happens only when the client required the SMTPUTF8 extension. var part *message.Part - if c.smtputf8 { + if c.smtputf8 || c.submission || mox.Pedantic { // Try to parse the message. // Do nothing if something bad happen during Parse and Walk, just keep the current value for c.msgsmtputf8. p, err := message.Parse(c.log.Logger, true, dataFile) @@ -1822,6 +1821,10 @@ func (c *conn) cmdData(p *parser) { c.log.Debug("SMTPUTF8 flag changed", slog.Bool("received SMTPUTF8", c.smtputf8), slog.Bool("evaluated SMTPUTF8", c.msgsmtputf8)) } } + if !c.smtputf8 && c.msgsmtputf8 && mox.Pedantic { + metricSubmission.WithLabelValues("missingsmtputf8").Inc() + xsmtpUserErrorf(smtp.C550MailboxUnavail, smtp.SeMsg6Other0, "smtputf8 extension is required but was not added to the MAIL command") + } // Prepare "Received" header. // ../rfc/5321:2051 ../rfc/5321:3302