Précédent   Forum du club des développeurs et IT Pro > Autres langages > Langages fonctionnels > Haskell
Haskell Forum d'entraide sur la programmation en langage fonctionnel Haskell
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse
 
Outils de la discussion
Publicité
'
Vieux 04/07/2012, 16h41   #1
sarfraz
Invité de passage
 
Inscription : juillet 2012
Messages : 3
Détails du profil
Informations forums :
Inscription : juillet 2012
Messages : 3
Points : 0
Points : 0
Par défaut envoyer un mail via gmail

Bonjour,

J'ai déjà effectué des recherches sur le net, mais ce n'est pas un sujet trés populaire.
Comme indiqué dans le titre, je voudrais envoyer un mail via gmail.
Cependant le service mail de google n'accepte que des connection via ssl.

Ok donc première tentative je me connecte, je balance un STARTTLS et je je me mets en ssl. Deuxieme tentative, je me connecte directement en ssl.
Pour l'instant j'en suis nul part...

Mes codes:
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import Network
import Network.TLS
import Network.TLS.Extra
import System.IO
import Text.Printf
import Crypto.Random
import qualified Data.ByteString as B
import Control.Monad (forever)
 
serv :: String
serv="smtp.gmail.com"

port :: String
port="465"

main=test2

params=TLSParams {pConnectVersion=SSL3
                 , pCiphers=ciphersuite_all
                 }

test2=do g <- newGenIO :: IO SystemRandom
         handle <- connectionClient serv port params g
         forever $ (recvData handle) >>= B.putStrLn
Grosso modo j'essaie de me co directement en ssl.
Mais ça ne marce pas. Quelqu'un aurait une solution, une piste, quoi que ce soit!!!!?
sarfraz est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/07/2012, 13h39   #2
sarfraz
Invité de passage
 
Inscription : juillet 2012
Messages : 3
Détails du profil
Informations forums :
Inscription : juillet 2012
Messages : 3
Points : 0
Points : 0
Jour,

Bon, j'ai un peu avancé.
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import Network
import Network.TLS
import Network.TLS.Extra
import System.IO
import Text.Printf
import Control.Monad (forever)
import Control.Concurrent (threadDelay)
import qualified Data.ByteString.Char8 as B
import Crypto.Random

serv :: String
serv = "smtp.gmail.com"
port :: Int
port   = 25 --that has to chage, I think

main :: IO ()
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

printSock :: Handle -> String -> IO ()
printSock h s = do write h s
                   hGetLine h >>= putStrLn
                   threadDelay 25
                   
params :: TLSParams
params=defaultParams {pConnectVersion=TLS12
                     ,pAllowedVersions=[TLS10, TLS11, TLS12]
                     ,pCiphers=ciphersuite_all}

test1 = do h <- connectTo serv (PortNumber (fromIntegral port))
           hSetBuffering h NoBuffering
           printSock h "EHLO"
           printSock h "STARTTLS"
           --google waits for tls handshake
           --the problem is from here
           g <- newGenIO :: IO SystemRandom
           tlsH <- client params g h
           handshake tlsH --the handshake is failling
Mon probleme cependant est toujours le meme. arriver a negocier cet echange TLS.
Franchement, je suis étonné par le manque de reponse que je reçois. Je veux dire jusqu'a maintenant les rares fois ou j'avais un probleme la communauté était hyper rapide.
Mais la j'ai l'impression que c'est un probleme qui ne concerne personne (juste un constat). Que ça soit ici ou sur #haskell ou SO d'ailleurs.

Bref si quelqu'un a des pistes sur google et tls...
J'ai regardé le code du client msmtp mais a vrai dire j'ai pas vraiment un niveau suffisant.
sarfraz est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/07/2012, 10h29   #3
Yo Eight
Membre confirmé
 
Homme
Ingénieur développement logiciels
Inscription : mai 2009
Messages : 89
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France

Informations professionnelles :
Activité : Ingénieur développement logiciels
Secteur : Finance

Informations forums :
Inscription : mai 2009
Messages : 89
Points : 285
Points : 285
La réponse est simple, votre problème n'est pas propre à Haskell mais au protocole de communication SSL. Avez vous regardez comment cela était implémenté dans d'autres langages que vous maîtrisés ?
Yo Eight est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 06h41.


 
 
 
 
Partenaires

Hébergement Web