Hier eine UDF von Blog4it
PHP Code:
Const $cdoSendUsingPickup = 1 ;Send message using the local SMTP service pickup directory.
Const $cdoSendUsingPort = 2 ;Send the message using the network (SMTP over the network).
Global $objmessage
Func _blog4itmail($betreff,$from,$from_name,$to,$smtp_server,$smtp_user, _
$smtp_passwort,$smtp_port = 25, $smpt_ssl = False)
Global $objMessage = ObjCreate("CDO.Message")
$objMessage.Subject = $betreff
$objMessage.From = '"'& $from_name &'" <'& $from &'>'
$objMessage.To = $to
$objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
;Name oder IP des SMTP Servers
$objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $smtp_server
;Type of authentication, NONE, Basic (Base64 encoded), NTLM
$objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1; 0=Do not authenticate / 1=basic (clear-text) authentication / 2=NTLM
;Your UserID on the SMTP server
$objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = $smtp_user
;Your password on the SMTP server
$objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $smtp_passwort
;Server port (typically 25)
$objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $smtp_port
;Use SSL for the connection (False or True)
$objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = $smpt_ssl
;Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
$objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
$objMessage.Configuration.Fields.Update
EndFunc
Func _blog4itmail_text($string)
$objMessage.TextBody = $string
EndFunc
Func _blog4itmail_textfromfile($strPfad)
Dim $f = FileOpen($strPfad,0)
$objMessage.TextBody = FileRead($f)
FileClose($f)
EndFunc
Func _blog4itmail_htmltext($string)
$objMessage.HTMLBody = $string
EndFunc
Func _blog4itmail_htmlfromurl($url)
$objMessage.CreateMHTMLBody ($url)
EndFunc
Func _blog4itmail_htmlfrompfad($strPfad)
$objMessage.CreateMHTMLBody ("file://" & $strPfad)
EndFunc
Func _blog4itmail_anhang($strPfad)
$objMessage.AddAttachment ($strPfad)
EndFunc
Func _blog4itmail_send()
$objmessage.send
EndFunc
Hier ein Beispiel
PHP Code:
#include <udfblog4itmail.au3>
_blog4itmail('Testnachricht ' & @HOUR & ':' & @MIN & ':' & @SEC , _
'ABSENDER EMAIL', _
'ABSENDER NAME', _
'EMPFÄNGER EMAIL', _
'SMTP MAIL SERVER (z.B. STMP.WEB.DE)', _
'SMTP ANMELDENAME', _
'SMTP PASSWORT', _
'SMTP PORT', _
false)
_blog4itmail_text('c:\test.html')
;_blog4itmail_anhang('c:\boot.ini') ; damit kann man .txt z.B versenden
;_blog4itmail_anhang('c:\config.sys')
_blog4itmail_send()
Noch ein beispiel
PHP Code:
Local $sendername, $username, $userpassword, $smtpserver
If FileExists('settings.ini') Then
If readSettings() = False Then
FileDelete('settings.ini')
MsgBox(16,"Fehler","Es wurden nicht alle benötigten Angaben gefunden, INI Datei gelöscht. Programm wird beendet.")
Exit
EndIf
Else
IniWrite('settings.ini','konto','sender',InputBox("Absender-Name","Bitte gib deine Absender Namen ein:","Hans Meiser"))
IniWrite('settings.ini','konto','from',InputBox("Absender-Mail","Bitte gib deine Absender Email ein:","[Only registered and activated users can see links. Click Here To Register...]"))
IniWrite('settings.ini','konto','password',InputBox("Passwort-Mail","Bitte gib dein Email-Passwort ein:","Passwort","*"))
IniWrite('settings.ini','konto','smtp',InputBox("Passwort-Mail","Bitte gib dem SMTP (Postausgangsserver) ein:","smtp.web.de"))
readSettings();
EndIf
Func readSettings()
$sendername = IniRead('settings.ini','konto','sender','null')
$username = IniRead('settings.ini','konto','from','null')
$userpassword = IniRead('settings.ini','konto','password','null')
$smtpserver = IniRead('settings.ini','konto','smtp','null')
If $sendername = 'null' Or $username = 'null' Or $userpassword = 'null' Or $smtpserver = 'null' then return False
Return True
EndFunc
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$frmMain = GUICreate("E-Mail Sender", 465, 280, 192, 124)
$lblReciver = GUICtrlCreateLabel("Empfänger:", 8, 8, 58, 17)
$txtReciver = GUICtrlCreateInput("[Only registered and activated users can see links. Click Here To Register...]", 80, 8, 217, 21)
$lblSubject= GUICtrlCreateLabel("Betreff:", 8, 35, 58, 17)
$txtSubject = GUICtrlCreateInput('Testnachricht ' & @HOUR & ':' & @MIN & ':' & @SEC , 80, 35, 217, 21)
$lblMsg = GUICtrlCreateLabel("Nachricht:", 8, 68, 53, 17)
$txtMsg = GUICtrlCreateEdit("", 80, 68, 377, 193)
$btnSend = GUICtrlCreateButton("Senden", 312, 8, 145, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $btnSend
sendMsg()
EndSwitch
WEnd
#include <udfblog4itmail.au3>
Func sendMsg()
_blog4itmail(GUICtrlRead($txtSubject), _
$username, _
$sendername, _
GUICtrlRead($txtReciver), _
$smtpserver, _
$username, _
$userpassword)
;_blog4itmail_text(GUICtrlRead($txtMsg))
;_blog4itmail_anhang('c:\boot.ini')
;_blog4itmail_anhang('c:\config.sys')
;_blog4itmail_htmlfromurl('http://blog4it.de');
_blog4itmail_send()
EndFunc