From a69ad12ec4e4226587094cbc87a67ab11d788385 Mon Sep 17 00:00:00 2001 From: "Daniel P. Wright" Date: Tue, 4 Feb 2014 08:34:45 +0900 Subject: [PATCH] Change SMTP example to use AUTH LOGIN Also, output the response on authentication failure rather than just carrying on regardless. --- examples/gmail.hs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/gmail.hs b/examples/gmail.hs index 63e3622..d3a3680 100644 --- a/examples/gmail.hs +++ b/examples/gmail.hs @@ -8,7 +8,7 @@ import Network.HaskellNet.SMTP.SSL import Network.HaskellNet.SSL -import Network.HaskellNet.Auth (AuthType(PLAIN)) +import Network.HaskellNet.Auth (AuthType(LOGIN)) import qualified Data.ByteString.Char8 as B @@ -30,8 +30,10 @@ imapTest = do where cfg = defaultSettingsIMAPSSL { sslMaxLineLength = 100000 } smtpTest = doSMTPSTARTTLS "smtp.gmail.com" $ \c -> do - sendCommand c $ AUTH PLAIN username password - sendMail username [recipient] mailContent c + r@(rsp, _) <- sendCommand c $ AUTH LOGIN username password + if rsp /= 235 + then print r + else sendMail username [recipient] mailContent c where mailContent = subject `B.append` body subject = "Subject: Test message\r\n\r\n" body = "This is a test message"