HaskellNet.SMTP test

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import Network.HaskellNet.SMTP
import Network.HaskellNet.Auth
import qualified Data.ByteString as B
import qualified Data.ByteString.Char8 as B8

main = do
  let sender = "my_sfr_address"
      receivers = ["my_gmail_add@gmail.com"]
      msg = B8.pack "This is a test message form Haskell program."
  h <- connectSMTPPort "smtp.sfr.fr" 587
  sendCommand h (AUTH LOGIN "my_sfr_address" "my_pwd")
  sendCommand h (MAIL sender)
  mapM (sendCommand h . RCPT) receivers
  (code, rep1) <- sendCommand h (DATA msg)
  putStrLn $ "Code: " ++ show code ++ "\nMessage: " ++ show rep1
  closeSMTP h

{- the answer I get is:
Code: 250
Message: "2.0.0 Ok: queued as EC8A47000086\r\n" 
But the mail is not sent, or at least not received in my gmail mailbox.
-}
13:3: Error: Use mapM_
Found:
mapM (sendCommand h . RCPT) receivers
Why not:
mapM_ (sendCommand h . RCPT) receivers