diff --git a/CHANGELOG.md b/CHANGELOG.md
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,3 +6,7 @@
 - compatibility with GHCs up to ghc 9.8 (bump base and bytestring)
 - fix example
 - add tested-with stanza
+
+## 0.4.0.1 -- 2025-01-17
+
+- Ignore 502 error on helo - fixes communication with some servers
diff --git a/HaskellNet-SSL.cabal b/HaskellNet-SSL.cabal
--- a/HaskellNet-SSL.cabal
+++ b/HaskellNet-SSL.cabal
@@ -1,6 +1,6 @@
 name:                HaskellNet-SSL
 synopsis:            Helpers to connect to SSL/TLS mail servers with HaskellNet
-version:             0.4.0.0
+version:             0.4.0.1
 description:         This package ties together the HaskellNet and connection
                      packages to make it easy to open IMAP and SMTP connections
                      over SSL.
diff --git a/src/Network/HaskellNet/SMTP/SSL.hs b/src/Network/HaskellNet/SMTP/SSL.hs
--- a/src/Network/HaskellNet/SMTP/SSL.hs
+++ b/src/Network/HaskellNet/SMTP/SSL.hs
@@ -52,7 +52,7 @@
 
     hn <- getHostName
     bsPut bs $ B.pack ("HELO " ++ hn ++ "\r\n")
-    getResponse bs >>= failIfNot bs 250
+    getResponse bs >>= failIfNotEx bs (`elem` [250, 502])
     bsPut bs $ B.pack ("EHLO " ++ hn ++ "\r\n")
     getResponse bs >>= failIfNot bs 250
     bsPut bs $ B.pack "STARTTLS\r\n"
@@ -71,6 +71,11 @@
 
 failIfNot :: BSStream -> Integer -> (Integer, String) -> IO ()
 failIfNot bs code (rc, rs) = when (code /= rc) closeAndFail
+  where closeAndFail = bsClose bs >> fail ("cannot connect to server: " ++ rs)
+
+-- | Extended version of fail if, can support multiple statuses
+failIfNotEx :: BSStream -> (Integer -> Bool) -> (Integer, String) -> IO ()
+failIfNotEx bs f (rc, rs) = unless (f rc) closeAndFail
   where closeAndFail = bsClose bs >> fail ("cannot connect to server: " ++ rs)
 
 -- This is a bit of a nasty hack.  Network.HaskellNet.SMTP.connectStream
