Using tls-extra for simple smtp

I am trying to write a simple script to send a mail via my gmail account. But I am a beginner so it is not that simple. I tryed google but exept for hackage, there is no help or examples at all. The problem is that I did not find the way to use tls-extra(or tls) to initiate the STARTTLS exchange. Ok, here is the code: import Network import Network.TLS.Extra import System.IO import Text.Printf server = "smtp.gmail.com" port = 25 --that has to chage, I think forever a = a >> forever a main = test1 write :: Handle -> String -> IO () write h s = do hPrintf h "%s\r\n" s printf "> %s\n" s listen :: Handle -> IO () listen h = forever $ hGetLine h >>= putStrLn test1 = do h <- connectTo server (PortNumber (fromIntegral port)) hSetBuffering h NoBuffering write h "EHLO" write h "STATTLS" listen h Another thing is that I use the listen function to know what is going on. But I cannot figure out how to use it along with write. That is to say, I would like to be able to see what is going on server-side while sending some data. I found two functions that may resolve my problems: connectionClient :: CryptoRandomGen g => String -> String -> TLSParams -> g -> IO (TLSCtx Handle) forkIO :: IO () -> IO ThreadId The first for tls and the second to send and receive at the same time. But can't seem to make them work. I hope I am not to messy here, any help would be appreciated. PS: English is not my native. -- Sarfraz K.

On Tue, 03 Jul 2012 17:16:37 +0200, Sarfraz K.
I am trying to write a simple script to send a mail via my gmail account. : test1 = do h <- connectTo server (PortNumber (fromIntegral port)) hSetBuffering h NoBuffering write h "EHLO" write h "STATTLS" listen h
I am not an expert in this matter, but I think you must change the line
write h "STATTLS"
to:
write h "STARTTLS"
Regards, Henk-Jan van Tuyl -- http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html Haskell programming --
participants (2)
-
Henk-Jan van Tuyl
-
Sarfraz K.