From 147a8b4d9870638513804173009b84f8b243d872 Mon Sep 17 00:00:00 2001 From: BlocksecPHD Date: Fri, 10 Apr 2026 05:10:53 +0800 Subject: [PATCH] Wrap email content to comply with SMTP line length limit Fixes #3665 - Long lines in whois output and log excerpts can exceed SMTP's maximum line length of 998 characters (RFC 5321), causing emails to bounce. Add fold -sw 900 to: - _whois command in mail-whois-common.conf - _grep_logs in helpers-common.conf This ensures lines are word-wrapped at 900 characters, leaving margin for safety. Using fold instead of cut preserves multi-byte UTF-8 characters correctly. --- config/action.d/helpers-common.conf | 3 ++- config/action.d/mail-whois-common.conf | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/config/action.d/helpers-common.conf b/config/action.d/helpers-common.conf index 03422a87..24e9fda9 100644 --- a/config/action.d/helpers-common.conf +++ b/config/action.d/helpers-common.conf @@ -4,7 +4,8 @@ # _grep_logs_args = 'test' # (printf %%b "Log-excerpt contains 'test':\n"; %(_grep_logs)s; printf %%b "Log-excerpt contains 'test':\n") | mail ... # -_grep_logs = logpath=""; grep %(_grep_logs_args)s $logpath | +# Wrap log lines to 900 chars to comply with SMTP line length limit (RFC 5321: max 998 chars) +_grep_logs = logpath=""; grep %(_grep_logs_args)s $logpath | fold -sw 900 | # options `-wF` used to match only whole words and fixed string (not as pattern) _grep_logs_args = -wF "" diff --git a/config/action.d/mail-whois-common.conf b/config/action.d/mail-whois-common.conf index ecf3a5d9..655c98a4 100644 --- a/config/action.d/mail-whois-common.conf +++ b/config/action.d/mail-whois-common.conf @@ -11,7 +11,8 @@ after = mail-whois-common.local [DEFAULT] #original character set of whois output will be sent to mail program -_whois = whois || echo "missing whois program" +# Wrap whois output to 900 chars to comply with SMTP line length limit (RFC 5321: max 998 chars) +_whois = whois | fold -sw 900 || echo "missing whois program" # use heuristics to convert charset of whois output to a target # character set before sending it to a mail program