Update gmail example
This commit is contained in:
parent
9357f7e609
commit
717f8e202a
@ -1,14 +1,9 @@
|
|||||||
{-# 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.Auth (AuthType(LOGIN))
|
||||||
import Network.HaskellNet.SMTP.SSL
|
|
||||||
|
|
||||||
import Network.HaskellNet.SSL
|
|
||||||
|
|
||||||
import Network.HaskellNet.Auth (AuthType(LOGIN))
|
|
||||||
|
|
||||||
import qualified Data.ByteString.Char8 as B
|
import qualified Data.ByteString.Char8 as B
|
||||||
|
|
||||||
@ -30,13 +25,12 @@ 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 ()
|
||||||
main = smtpTest >> imapTest >> return ()
|
main = smtpTest >> imapTest >> return ()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user