autoit _INetSmtpMail non funzionante

« Older   Newer »
  Share  
MatteoJug
CAT_IMG Posted on 26/5/2008, 17:38 by: MatteoJug     +1   -1




Anchio molto tempo fa ho incontrato questo problema, pero sono riuscito a risolverlo facendomi una funzione che consentiva l'invio dell'email atraverso il protocollo TCP.
la funzione:
CODICE
Func _SendMail($user,$pass,$server,$from,$to,$port=25,$obj="OGGETTO",$msg="MESSAGGIO",$visibile=False)
       $msg=StringReplace($msg,@CRLF & "." & @CRLF,@CRLF & "," & @CRLF)
       $limit_time=15000
       if $visibile=True Then SplashTextOn("Send Email","Inizio Connessione...",200,100)
       TCPStartup()
       $main_sock=TCPConnect(TCPNameToIP($server),$port)
       $timer=TimerInit()
       while TimerDiff($timer)<$limit_time
               $rec=TCPRecv($main_sock,1000)
               if $rec<>"" then ExitLoop
       WEnd
       $timer=0
       if $rec="" then Return SetError(1,0,0)
       if $visibile=True Then SplashTextOn("Send Email","Connessione stabilita" & @CRLF & "Richiesta al server",200,100)
       TCPSend($main_sock,"HELO EMAIL" & @CRLF)
       $timer=TimerInit()
       while TimerDiff($timer)<$limit_time
               $rec=TCPRecv($main_sock,1000)
               if $rec<>"" then ExitLoop
       WEnd
       $timer=0
       if $rec="" then Return SetError(1,0,0)
       if $visibile=True Then SplashTextOn("Send Email","Connessione stabilita" & @CRLF & "Login in corso...",200,100)
       TCPSend($main_sock,"AUTH LOGIN" & @CRLF)
       $timer=TimerInit()
       while TimerDiff($timer)<$limit_time
               $rec=TCPRecv($main_sock,1000)
               if $rec<>"" then ExitLoop
       WEnd
       $timer=0
       if $rec="" then Return SetError(1,0,0)
       TCPSend($main_sock,$user & @CRLF)
       $timer=TimerInit()
       while TimerDiff($timer)<$limit_time
               $rec=TCPRecv($main_sock,1000)
               if $rec<>"" then ExitLoop
       WEnd
       $timer=0
       TCPSend($main_sock,$pass & @CRLF)
       $timer=TimerInit()
       while TimerDiff($timer)<$limit_time
               $rec=TCPRecv($main_sock,1000)
               if $rec<>"" then ExitLoop
       WEnd
       $timer=0
       if $rec="" then Return SetError(1,0,0)
       if $visibile=True Then SplashTextOn("Send Email","Connessione stabilita" & @CRLF & "Invio email in corso...",200,100)
       TCPSend($main_sock,"MAIL FROM:<" & $from & ">" & @CRLF)
       $timer=TimerInit()
       while TimerDiff($timer)<$limit_time
               $rec=TCPRecv($main_sock,1000)
               if $rec<>"" then ExitLoop
       WEnd
       $timer=0
       if $rec="" then Return SetError(1,0,0)
       TCPSend($main_sock,"RCPT TO:<" & $to & ">" & @CRLF)
       $timer=TimerInit()
       while TimerDiff($timer)<$limit_time
               $rec=TCPRecv($main_sock,1000)
               if $rec<>"" then ExitLoop
       WEnd
       $timer=0
       TCPSend($main_sock,"DATA" & @CRLF)
       $timer=TimerInit()
       while TimerDiff($timer)<$limit_time
               $rec=TCPRecv($main_sock,1000)
               if $rec<>"" then ExitLoop
       WEnd
       $timer=0
       if $rec="" then Return SetError(1,0,0)
       TCPSend($main_sock,"SUBJECT:" & $obj & @CRLF)
       TCPSend($main_sock,"" & @CRLF)
       TCPSend($main_sock,$msg & @CRLF & "." & @CRLF)
       $timer=TimerInit()
       while TimerDiff($timer)<$limit_time
               $rec=TCPRecv($main_sock,1000)
               if $rec<>"" then ExitLoop
       WEnd
       $timer=0
       if $rec="" then Return SetError(1,0,0)
       if $visibile=True Then SplashOff()
       TCPCloseSocket($main_sock)
       TCPShutdown()
       Return $rec
EndFunc

L'ho ritestata ora ed ha funzionato, perņ una cosa importantissima:
L'username e la password DEVONO essere in Base64, in quanto senno il server non li riconosce.
Ditemi se non vi funziona.
 
Top
12 replies since 25/5/2008, 19:58   966 views
  Share