From 846e3b9a372c124c553aeb6858e8d650dffaa95a Mon Sep 17 00:00:00 2001 From: Nicolai Langfeldt Date: Thu, 24 Apr 2025 11:17:35 +0200 Subject: [PATCH] Support HELO --- client.go | 13 +++++++++++++ server.go | 1 + 2 files changed, 14 insertions(+) diff --git a/client.go b/client.go index 5579a1c..3605e6d 100644 --- a/client.go +++ b/client.go @@ -92,12 +92,25 @@ func sendMail(e *mail.Envelope, config *relayConfig) error { } func handshake(client *smtp.Client, config *relayConfig, tlsConfig *tls.Config) error { + if config.HeloHost != "" { + if err := client.Hello(config.HeloHost); err != nil { + return errors.Wrap(err, "HELO error") + } + } + if config.STARTTLS { if err := client.StartTLS(tlsConfig); err != nil { return errors.Wrap(err, "starttls error") } + // Re-HELO after STARTTLS + if config.HeloHost != "" { + if err := client.Hello(config.HeloHost); err != nil { + return errors.Wrap(err, "HELO error") + } + } } + var auth smtp.Auth if config.LoginAuthType { auth = LoginAuth(config.Username, config.Password) diff --git a/server.go b/server.go index cd9994f..96bc218 100644 --- a/server.go +++ b/server.go @@ -64,6 +64,7 @@ type relayConfig struct { Username string `json:"smtp_username"` Password string `json:"smtp_password"` SkipVerify bool `json:"smtp_skip_cert_verify"` + HeloHost string `json:"smtp_helo"` } // mailRelayProcessor decorator relays emails to another SMTP server.