Compare commits

..

2 Commits

Author SHA1 Message Date
H0llyW00dzZ
27d8234af4
Merge e83d5a0695 into 8df4a2670b 2025-04-14 08:43:35 +00:00
H0llyW00dzZ
e83d5a0695
Improve Format HELO/EHLO Name
- [+] feat(email.go): add formatHeloName function to format HELO identifier and update getHeloName to use it
2025-04-14 15:42:54 +07:00

View File

@ -16,20 +16,28 @@ func shouldAuth() bool {
return config.SMTPAccount != "" || config.SMTPToken != "" 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 // getHeloName returns a HELO identifier combining system name and pod name
func getHeloName() string { func getHeloName() string {
// Get pod name from environment (Kubernetes sets this automatically) // Get pod name from environment (Kubernetes sets this automatically)
podName := os.Getenv("HOSTNAME") podName := os.Getenv("HOSTNAME")
// Create a HELO-compatible string (replace spaces with hyphens) // Format the system name to be HELO compatible
systemName := strings.ReplaceAll(config.SystemName, " ", "-") formattedName := formatHeloName(config.SystemName)
if podName != "" { if podName != "" {
return fmt.Sprintf("%s-%s", systemName, podName) return fmt.Sprintf("%s-%s", formattedName, podName)
} }
// Fallback if not running in Kubernetes // Fallback if not running in Kubernetes
return systemName return formattedName
} }
// SendEmail sends an email with the given subject, receiver, and content // SendEmail sends an email with the given subject, receiver, and content