diff --git a/internal/smtpd/forward.go b/internal/smtpd/forward.go index 7f7978c..98fe9cf 100644 --- a/internal/smtpd/forward.go +++ b/internal/smtpd/forward.go @@ -4,6 +4,7 @@ import ( "crypto/tls" "fmt" "net/smtp" + "os" "strings" "github.com/axllent/mailpit/config" @@ -60,6 +61,13 @@ func createForwardingSMTPClient(config config.SMTPForwardConfigStruct, addr stri } } + // Set the hostname for HELO/EHLO + if hostname, err := os.Hostname(); err == nil { + if err := client.Hello(hostname); err != nil { + return nil, fmt.Errorf("error saying HELO/EHLO to %s: %v", addr, err) + } + } + // Note: The caller is responsible for closing the client return client, nil } diff --git a/internal/smtpd/relay.go b/internal/smtpd/relay.go index 66c2829..5e94b0a 100644 --- a/internal/smtpd/relay.go +++ b/internal/smtpd/relay.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "net/smtp" + "os" "strings" "github.com/axllent/mailpit/config" @@ -94,6 +95,13 @@ func createRelaySMTPClient(config config.SMTPRelayConfigStruct, addr string) (*s } } + // Set the hostname for HELO/EHLO + if hostname, err := os.Hostname(); err == nil { + if err := client.Hello(hostname); err != nil { + return nil, fmt.Errorf("error saying HELO/EHLO to %s: %v", addr, err) + } + } + // Note: The caller is responsible for closing the client return client, nil }