While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $send_B
Dim $as_Body[1]
$as_Body[0] = GUICtrlRead($text_I)
$Response = _INetSmtpMailAuth($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_UName, $s_PWD, GUICtrlRead($s_Subject), $as_Body)
$err = @error
If $Response = 1 Then
MsgBox(0, "Success!", "Mail sent")
Else
MsgBox(0, "Error!", "Mail failed with error code " & $err)
EndIf
EndSwitch
WEnd
;===============================================================================
;
; Function Name: _INetSmtpMailAuth()
; Description: Sends an email using SMTP over TCP IP.
; Parameter(s): $s_SmtpServer - SMTP server to be used for sending email
; $s_FromName - Name of sender
; $s_FromAddress - eMail address of sender
; $s_ToAddress - Address that email is to be sent to
; $s_Username - Username for Authentication (bernd670)
; $s_Passwd - Password for Authentication (bernd670)
; $s_Subject - Subject of eMail
; $as_Body - Single dimension array containing the body of eMail as strings
; $s_helo - Helo identifier (default @COMPUTERNAME) sometime needed by smtp server
; $s_first - send before Helo identifier (default @CRLF) sometime needed by smtp server
; $b_trace - trace on a splash window (default 0 = no trace)
; Requirement(s): None
; Return Value(s): On Success - Returns 1
; On Failure - 0 and sets
; @ERROR = 1 - Invalid Parameters
; @ERROR = 2 - Unable to start TCP
; @ERROR = 3 - Unable to resolve IP
; @ERROR = 4 - Unable to create socket
; @ERROR = 5x - Cannot open SMTP session
; @ERROR = 50x - Cannot send body
; @ERROR = 5000 - Cannot close SMTP session
; Authors: Original function to send email via TCP - Asimzameer
; Conversion to UDF - Walkabout
; Correction Helo, timeout, trace - Jpm
; Correction send before Helo - Jpm
; Include Authentication - bernd670
;
;===============================================================================
Func _INetSmtpMailAuth($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Username, $s_Passwd, $s_Subject = "", $as_Body = "", $s_helo = "", $s_first = "-1", $b_trace = 0)
Local $v_Socket
Local $s_IPAddress
Local $i_Count
Local $s_Send[9]
Local $s_ReplyCode[9];Return code from SMTP server indicating success
If $s_SmtpServer = "" Or $s_FromAddress = "" Or $s_ToAddress = "" Or $s_Username = "" Or $s_Passwd = "" Or $s_FromName = "" Or StringLen($s_FromName) > 256 Then
SetError(1)
Return 0
EndIf
If $s_helo = "" Then $s_helo = @ComputerName
If TCPStartup() = 0 Then
SetError(2)
Return 0
EndIf
StringRegExp($s_SmtpServer, "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)")
If @extended Then
$s_IPAddress = $s_SmtpServer
Else
$s_IPAddress = TCPNameToIP($s_SmtpServer)
EndIf
If $s_IPAddress = "" Then
TCPShutdown()
SetError(3)
Return 0
EndIf
$v_Socket = TCPConnect($s_IPAddress, 25)
If $v_Socket = -1 Then
TCPShutdown()
SetError(4)
Return (0)
EndIf
; open stmp session
If _SmtpSend($v_Socket, $s_Send[0], $s_ReplyCode[0], $b_trace, "220", $s_first) Then
SetError(50)
Return 0
EndIf
; send header
For $i_Count = 0 To UBound($s_Send) - 2
If _SmtpSend($v_Socket, $s_Send[$i_Count], $s_ReplyCode[$i_Count], $b_trace) Then
SetError(50 + $i_Count)
Return 0
EndIf
Next
; send body records (a record can be multiline : take care of a subline beginning with a dot should be ..)
For $i_Count = 0 To UBound($as_Body) - 1
; correct line beginning with a dot
If StringLeft($as_Body[$i_Count], 1) = "." Then $as_Body[$i_Count] = "." & $as_Body[$i_Count]
If _SmtpSend($v_Socket, $as_Body[$i_Count] & @CRLF, "", $b_trace) Then
SetError(500 + $i_Count)
Return 0
EndIf
Next
; close the smtp session
$i_Count = UBound($s_Send) - 1
If _SmtpSend($v_Socket, $s_Send[$i_Count], $s_ReplyCode[$i_Count], $b_trace) Then
SetError(5000)
Return 0
EndIf
Es steht doch nun wirklich alles da.
Dir fehlt es einfach an dem Grundverständnis wie "E-Mail" überhaupt funktioniert.
Also wenn du programmatisch E-Mails versenden willst solltest du schon ein Grundverständnis von der Materie mit bringen.
Typischer Fall von Copy&Paste-Fail.
Das hier sollte schon reichen. E-Mail ? Wikipedia
Die genauen Informationen erhälst du bei deinem E-Mail Anbieter, wenn du es selber bist frage ich mich wie du das hin bekommen hast einen SMTP Server einzurichten.
Das ist doch schon alles hintendran erklärt. Mit ein wenig Englischkenntnissen sollte das kein Problem sein.
PHP Code:
$s_SmtpServer - SMTP server to be used for sending email ; $s_FromName - Name of sender ; $s_FromAddress - eMail address of sender ; $s_ToAddress - Address that email is to be sent to ; $s_Username - Username for Authentication (bernd670) ; $s_Passwd - Password for Authentication (bernd670) ; $s_Subject - Subject of eMail ; $as_Body - Single dimension array containing the body of eMail as strings ; $s_helo - Helo identifier (default @COMPUTERNAME) sometime needed by smtp server ; $s_first - send before Helo identifier (default @CRLF) sometime needed by smtp server ; $b_trace - trace on a splash window (default 0 = no trace)