Sean wrote:
What SMTP server did you use? Better post the whole code you used.
sorry, yeah that might help--lol.
I changed nothing except used my gmail address and password.
Code:
/*
protect your hardware
The script starts with the PC, try to get the external IP and send an email with the pc-name and IP-number.
It does this only if the IP changes. For the autostart it writes to registry.
You've to add your email data and then you should compile the script with nodecompile.
To use it, put the compiled Exe somewhere and start it once. Then you get periodically emails with
the external IP.
author: haichen 2009
used code:
--------------
cdo com - email delivery
author sean
http://www.autohotkey.com/forum/viewtopic.php?t=39797
com - standard library
code from sean
http://www.autohotkey.com/forum/viewtopic.php?p=146242#146242
URLDownloadToVar
from Olfen
http://www.autohotkey.com/forum/viewtopic.php?p=64230#64230
Retrieve "external IP Adress"
from SKAN
http://www.autohotkey.com/forum/viewtopic.php?p=42420#42420
IP-number pattern
http://regexlib.com
Get your extern IP
http://Checkip.dyndns.org/
This script:
http://www.autohotkey.com/forum/viewtopic.php?p=316526#316526
*/
#NoTrayIcon
#include COM.ahk
;~ ; filename where to store the IP-number
;~ tmp=m189hhj.tmp
;~ TmpFile=%WinDir%\TEMP\%tmp%
;~ ; get your external IP
;~ MyExternalIPText := UrlDownloadToVar("http://Checkip.dyndns.org/")
;~ pattern=\b(([01]?\d?\d|2[0-4]\d|25[0-5])\.){3}([01]?\d?\d|2[0-4]\d|25[0-5])\b
;~ FoundPos := RegExMatch(MyExternalIPText, pattern, IP)
;~ ;-----------------------------------------------------------------
;~ ; if you install the program as a service you should comment this block
;~ ;Autostart
;~ regname=mip
;~ If a_isCompiled
;~ RegWrite,REG_SZ,HKEY_CURRENT_USER,Software\Microsoft\Windows\CurrentVersion\Run,%regname%,"%A_ScriptDir%\%A_ScriptName%"
;~ ;-----------------------------------------------------------------
;~ ; change your email params here
sFrom := "blah@gmail.com"
sTo := "blah@gmail.com"
sSubject := "asdfasdfasdfasdfsde"
sBody = Blah yadda yadda blah
sAttach := ;"Path_Of_Attachment" ; can add Multiple attachments, the Delimiter is |
sServer := "smtp.gmail.com" ; specify your SMTP server
nPort := 465 ; 25
bTLS := True ; False
nSend := 2 ; cdoSendUsingPort
nAuth := 1 ; cdoBasic
sUsername := "blah@gmail.com"
sPassword := "xxxxx"
;-----------------------------------------------------------------
;~ FileReadLine,oldIP,%TmpFile%,1
;~ If ((ip<>"") and (oldIP <> ip) )
;~ {
;~ FileDelete,%TmpFile%
;~ FileAppend, %IP%`n ,%TmpFile%
COM_Init()
pmsg := COM_CreateObject("CDO.Message")
pcfg := COM_Invoke(pmsg, "Configuration")
pfld := COM_Invoke(pcfg, "Fields")
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/Sendusing", nSend)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout", 60)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/smtpserver", sServer)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/smtpserverport", nPort)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/smtpusessl", bTLS)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", nAuth)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/Sendusername", sUsername)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/SendPassword", sPassword)
COM_Invoke(pfld, "Update")
COM_Invoke(pmsg, "From", sFrom)
COM_Invoke(pmsg, "To", sTo)
COM_Invoke(pmsg, "Subject", sSubject)
COM_Invoke(pmsg, "TextBody", sBody)
Loop, Parse, sAttach, |, %A_Space%%A_Tab%
COM_Invoke(pmsg, "AddAttachment", A_LoopField)
COM_Invoke(pmsg, "Send")
COM_Release(pfld)
COM_Release(pcfg)
COM_Release(pmsg)
COM_Term()
;~ }
Return
;functions
UrlDownloadToVar(URL, Proxy="", ProxyBypass="") {
AutoTrim, Off
hModule := DllCall("LoadLibrary", "str", "wininet.dll")
If (Proxy != "")
AccessType=3
Else
AccessType=1
;INTERNET_OPEN_TYPE_PRECONFIG 0 // use registry configuration
;INTERNET_OPEN_TYPE_DIRECT 1 // direct to net
;INTERNET_OPEN_TYPE_PROXY 3 // via named proxy
;INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY 4 // prevent using java/script/INS
io_hInternet := DllCall("wininet\InternetOpenA"
, "str", "" ;lpszAgent
, "uint", AccessType
, "str", Proxy
, "str", ProxyBypass
, "uint", 0) ;dwFlags
iou := DllCall("wininet\InternetOpenUrlA"
, "uint", io_hInternet
, "str", url
, "str", "" ;lpszHeaders
, "uint", 0 ;dwHeadersLength
, "uint", 0x80000000 ;dwFlags: INTERNET_FLAG_RELOAD = 0x80000000 // retrieve the original item
, "uint", 0) ;dwContext
If (ErrorLevel != 0 or iou = 0) {
DllCall("FreeLibrary", "uint", hModule)
Return 0
}
VarSetCapacity(buffer, 512, 0)
VarSetCapacity(NumberOfBytesRead, 4, 0)
Loop
{
irf := DllCall("wininet\InternetReadFile", "uint", iou, "uint", &buffer, "uint", 512, "uint", &NumberOfBytesRead)
NOBR = 0
Loop 4 ; Build the Integer by adding up its bytes. - ExtractInteger
NOBR += *(&NumberOfBytesRead + A_Index-1) << 8*(A_Index-1)
IfEqual, NOBR, 0, Break
;BytesReadTotal += NOBR
DllCall("lstrcpy", "str", buffer, "uint", &buffer)
res = %res%%buffer%
}
StringTrimRight, res, res, 2
DllCall("wininet\InternetCloseHandle", "uint", iou)
DllCall("wininet\InternetCloseHandle", "uint", io_hInternet)
DllCall("FreeLibrary", "uint", hModule)
AutoTrim, on
Return, res
}