


Procedure send(msg.s)
Global resultSM.s, connectionID
SendNetworkData (connectionID,@msg, Len (msg))
EndProcedure
Procedure.l SendMail(ServerIP.s, mailto.s, mailfrom.s, subject.s, msgbody.s, port) ; Envoie un message à l'adresse mail choisie (vous pouvez utiliser GetIP pour obtenir l'adresse IP) (port=25 la plupart du temps)
Global resultSM.s, connectionID
If InitNetwork ()
connectionID = OpenNetworkConnection (ServerIP,port)
If connectionID
wait()
error=0
If resultSM= "220"
send( "HELO CGIapp" + #CRLF$ )
wait()
If resultSM= "250"
Delay (100)
send( "MAIL FROM: <" +mailfrom+ ">" + #CRLF$ )
wait()
If resultSM= "250"
send( "RCPT TO: <" +mailto+ ">" + #CRLF$ )
wait()
If resultSM= "250"
send( "DATA" + #CRLF$ )
wait()
If resultSM= "354"
Delay (100)
send( "Date: " + #CRLF$ )
send( "From: <" +mailfrom+ ">" + #CRLF$ )
send( "To: <" +mailto+ ">" + #CRLF$ )
send( "Subject: " +subject+ #CRLF$ )
send( "X-Mailer: PBMailer" + #CRLF$ )
Delay (100)
send( "--" + #CRLF$ + "--" + #CRLF$ + #CRLF$ )
send(msgbody)
Delay (100)
send( "" + #CRLF$ )
send( "." + #CRLF$ )
wait()
If resultSM= "250"
Delay (100)
send( "QUIT" + #CRLF$ )
wait()
ProcedureReturn 1
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
CloseNetworkConnection (connectionID)
EndIf
EndIf
EndProcedure