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
5252
5353 hn <- getHostName
5454 bsPut bs $ B. pack (" HELO " ++ hn ++ " \r\n " )
55- getResponse bs >>= failIfNot bs 250
55+ getResponse bs >>= failIfNotEx bs ( `elem` [ 250 , 502 ])
5656 bsPut bs $ B. pack (" EHLO " ++ hn ++ " \r\n " )
5757 getResponse bs >>= failIfNot bs 250
5858 bsPut bs $ B. pack " STARTTLS\r\n "
@@ -73,6 +73,11 @@ failIfNot :: BSStream -> Integer -> (Integer, String) -> IO ()
7373failIfNot bs code (rc, rs) = when (code /= rc) closeAndFail
7474 where closeAndFail = bsClose bs >> fail (" cannot connect to server: " ++ rs)
7575
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+
7681-- This is a bit of a nasty hack. Network.HaskellNet.SMTP.connectStream
7782-- expects to receive a status 220 from the server as soon as it connects,
7883-- but we've intercepted it in order to establish a STARTTLS connection.
You can’t perform that action at this time.
0 commit comments