From e83d5a06950fd386b218fa0c13a486d29e7bc4b3 Mon Sep 17 00:00:00 2001 From: H0llyW00dzZ Date: Mon, 14 Apr 2025 15:42:54 +0700 Subject: [PATCH] Improve Format HELO/EHLO Name - [+] feat(email.go): add formatHeloName function to format HELO identifier and update getHeloName to use it --- common/message/email.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/common/message/email.go b/common/message/email.go index 6006209f..419ec788 100644 --- a/common/message/email.go +++ b/common/message/email.go @@ -16,20 +16,28 @@ func shouldAuth() bool { return config.SMTPAccount != "" || config.SMTPToken != "" } +// formatHeloName formats a string to be HELO compatible: +// - Converts to lowercase (for English compatibility) +// - Replaces spaces with hyphens +func formatHeloName(name string) string { + // Convert to lowercase and replace spaces with hyphens + return strings.ReplaceAll(strings.ToLower(name), " ", "-") +} + // getHeloName returns a HELO identifier combining system name and pod name func getHeloName() string { // Get pod name from environment (Kubernetes sets this automatically) podName := os.Getenv("HOSTNAME") - // Create a HELO-compatible string (replace spaces with hyphens) - systemName := strings.ReplaceAll(config.SystemName, " ", "-") + // Format the system name to be HELO compatible + formattedName := formatHeloName(config.SystemName) if podName != "" { - return fmt.Sprintf("%s-%s", systemName, podName) + return fmt.Sprintf("%s-%s", formattedName, podName) } // Fallback if not running in Kubernetes - return systemName + return formattedName } // SendEmail sends an email with the given subject, receiver, and content