Chore: Use local hostname for EHLO/HELO in SMTP communication

This commit is contained in:
Ralph Slooten
2026-03-09 12:38:34 +13:00
parent a72d42c8d4
commit ab3fc5ead7

View File

@@ -90,7 +90,13 @@ func sendMail(addr string, a smtp.Auth, from string, to []string, msg []byte) er
}
defer func() { _ = c.Close() }()
if err = c.Hello(addr); err != nil {
// Use the local hostname for EHLO/HELO as required by RFC 5321.
// Fall back to "localhost" if the hostname cannot be determined.
localHostname, err := os.Hostname()
if err != nil {
localHostname = "localhost"
}
if err = c.Hello(localHostname); err != nil {
return err
}