Jump to content

Check Wan IP with Email Notification


dreniarb
 Share

Recommended Posts

Been looking for something like this for a few years now. Never could find a "simple" program to alert me when a customer's ip address changes. I think this is about as simple as it gets (until Autoit has it's own built in smtp engine that is). Got the idea from Wb-Freekill's PCinfo script.

Forum topic

Basically, it checks the file wanip.txt (created after first use of the script) and stores the ip address found in it.

It then checks whatismyip.org for the ip address, and plugs it into wanip.txt.

If the ip's are the same, it exits.

If they're different, it uses blat to send an email with the contents of wanip.txt (the ip address).

$To = IniRead(@Homedrive & "wanip.ini", "Settings", "To", "")
$From = IniRead(@Homedrive & "wanip.ini", "Settings", "From", "")
$SMTP = IniRead(@Homedrive & "wanip.ini", "Settings", "SMTP", "")
$Site = IniRead(@Homedrive & "wanip.ini", "Settings", "Site", "")

$FILE = FileOpen(@Homedrive & "wanip.txt", 0)
$LINE1 = FileReadLine($FILE)

$IP = URLDownloadToFile ($Site, @Homedrive & "wanip.txt")

$FILE = FileOpen(@Homedrive & "wanip.txt", 0)
$LINE = FileReadLine($FILE)
FileClose(@Homedrive & "wanip.txt")

If $Line1 = $Line Then
    Exit
Else
RunWait(@ComSpec & " /c " & 'blat wanip.txt -to ' & $To & ' -f ' & $From & ' -server ' & $SMTP, "", @SW_HIDE)

EndIf

Here's the wanip.ini file format:

[Settings]
smtp=mail.server.com
site=http://whatismyip.org
to=you@yourdomain.com
from=anynamehere@nottooimportant.com

You need blat in the same folder as the script and ini file:

Blat

To get around needing authentication on the mail server, I used my own mail server (the one that hosts my email). Since the email is going to an account on it, it doesn't ask for authentication (ie, it's not trying to relay).

I'd like to have blat use a different subject. It's not necessary, but it would just look nicer. But when I try to put in a subject (-subject "Here's my new ip"), it won't email. Maybe autoit doesn't like the quotes?

Let me know what you guys think or if any of the code could be tightened up.

I hope some of you out there find this useful.

Link to comment
Share on other sites

  • 2 weeks later...

Nice one.

I actually wrote the same thing (sorta) in PHP. Supports DNS registering, FTP, and email.

Check this out:

http://www.shrum.net/code/?body=./wan2web/home.html

o:)

Odd...I called my log file wanip.txt too

:lmao:

FYI: I just noticed the http://whatismyip.org...I've been hosting my own WAN IP display at http://www.shrum.net/getip.php

Edited by sshrum

Sean Shrum :: http://www.shrum.net

All my published AU3-based apps and utilities

'Make it idiot-proof, and someone will make a better idiot'

 

Link to comment
Share on other sites

  • 11 years later...
On 3/5/2016 at 0:38 PM, bootlesnet said:

can you share me this file getip.php sshrum?!

thank you!

well, in 2005 ... ok, anyway, here "http://stackoverflow.com/questions/13646690/how-to-get-real-ip-from-visitor" and as far as that,  I'd use STUN_GetMyIP()   =)

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...