File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
src/Network/HaskellNet/SMTP Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ connectSTARTTLS hostname cfg = do
52
52
53
53
hn <- getHostName
54
54
bsPut bs $ B. pack (" HELO " ++ hn ++ " \r\n " )
55
- getResponse bs >>= failIfNot bs 250
55
+ getResponse bs >>= failIfNotEx bs ( `elem` [ 250 , 502 ])
56
56
bsPut bs $ B. pack (" EHLO " ++ hn ++ " \r\n " )
57
57
getResponse bs >>= failIfNot bs 250
58
58
bsPut bs $ B. pack " STARTTLS\r\n "
@@ -73,6 +73,11 @@ failIfNot :: BSStream -> Integer -> (Integer, String) -> IO ()
73
73
failIfNot bs code (rc, rs) = when (code /= rc) closeAndFail
74
74
where closeAndFail = bsClose bs >> fail (" cannot connect to server: " ++ rs)
75
75
76
+ -- | Extended version of fail if, can support multiple statuses
77
+ failIfNotEx :: BSStream -> (Integer -> Bool ) -> (Integer , String ) -> IO ()
78
+ failIfNotEx bs f (rc, rs) = unless (f rc) closeAndFail
79
+ where closeAndFail = bsClose bs >> fail (" cannot connect to server: " ++ rs)
80
+
76
81
-- This is a bit of a nasty hack. Network.HaskellNet.SMTP.connectStream
77
82
-- expects to receive a status 220 from the server as soon as it connects,
78
83
-- but we've intercepted it in order to establish a STARTTLS connection.
You can’t perform that action at this time.
0 commit comments