Update gmail example

This commit is contained in:
Leza Morais Lutonda (Lemol-C) 2015-04-08 23:58:44 -04:00
parent 9357f7e609
commit 717f8e202a

View File

@ -1,12 +1,7 @@
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}
import Network.HaskellNet.IMAP
import Network.HaskellNet.IMAP.SSL import Network.HaskellNet.IMAP.SSL
import Network.HaskellNet.SMTP.SSL as SMTP
import Network.HaskellNet.SMTP
import Network.HaskellNet.SMTP.SSL
import Network.HaskellNet.SSL
import Network.HaskellNet.Auth (AuthType(LOGIN)) import Network.HaskellNet.Auth (AuthType(LOGIN))
@ -30,12 +25,11 @@ imapTest = do
where cfg = defaultSettingsIMAPSSL { sslMaxLineLength = 100000 } where cfg = defaultSettingsIMAPSSL { sslMaxLineLength = 100000 }
smtpTest = doSMTPSTARTTLS "smtp.gmail.com" $ \c -> do smtpTest = doSMTPSTARTTLS "smtp.gmail.com" $ \c -> do
r@(rsp, _) <- sendCommand c $ AUTH LOGIN username password authSucceed <- SMTP.authenticate LOGIN username password c
if rsp /= 235 if authSucceed
then print r then print "Authentication error."
else sendMail username [recipient] mailContent c else sendPlainTextMail recipient username subject body c
where mailContent = subject `B.append` body where subject = "Test message"
subject = "Subject: Test message\r\n\r\n"
body = "This is a test message" body = "This is a test message"
main :: IO () main :: IO ()