Mikrotik send current/connected IP to my email address

Hi friend,

My Mikrotik ROS version 3.30, I have a PPP0e internet connection, that is show dynamic ip and it have changed after some hour. I want Mikrotik ROS send me current/connected IP address by email after some hour. Is it possible, If so please give me details how to possible it.

Best regards,
Nishadul

If your mikrotik router makes the pppoe connection, you should add a script like this:

:local ipadd [/ip address get [find interface=pppoe-modem  ] address ];
:local msg (" My ip is: $ipadd");
/tool e-mail send to="email@gmail.com" subject="My Ip" body=$msg  server=[:resolve smtp.gmail.com] tls=yes;

1.JPG

You might want to check the dynamic dns update scripts. Instead of using IP to connect to your router, you
can connect to it by assigning a domain name which updates through scripts.
There are a lot of webpages which do offer a domain name for free. I have used changeip in several cases,
but you can pick any other and try it out.

https://www.google.com/search?q=dynamic+dns&sitesearch=http://wiki.mikrotik.com&ie=utf-8&oe=utf-8

I have make a script as like your suggestion but mikrotik do not send email after changed the ip. see the attach file.

When I am exit from winbox then script automatically stop but why stop I do not understand, my server is continue running.
mikrotik.doc (85 KB)

First of all you have to be sure to write your email settings in mikrotik:

/tool e-mail
set address=0.0.0.0 from=username@gmail.com password=pass port=\
    25 starttls=no user=username

Email setting, see the attach file, Is it OK,
When I am exit from winbox then script automatically stop but why stop I do not understand, my server is continue running.
email.doc (72 KB)

When I am exit from winbox then script automatically stop but why stop I do not understand, my server is continue running.

If you want your script to run automatically you should add a scheduler to this.
This is how to add it if your script named: email and want to run it every 6 hours.

/system scheduler
add disabled=no interval=06:00:00 name=email on-event=email policy=\
    reboot,read,write,policy,test,password,sniff,sensitive start-date=\
    jan/01/1970 start-time=03:30:00

Please see my attach file, my setting is Ok or Not because I am not finding backup mail to my mail account.
Please confirm it.
auto backup.doc (195 KB)

I just run the below srcipt and the email arrived with the backup file.
Run this first, if email not arrive check again with a gmail account like i did.

add name=test_mail policy=ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive,api source="#make the backup file\r\
    \n/system backup save name=[/system identity get name];\r\
    \n#wait 2 seconds\r\
    \n:delay 2;\r\
    \n#get name date and time\r\
    \n:local name [/system identity get name];\r\
    \n:local date [/system clock get date];\r\
    \n:local time [/system clock get time];\r\
    \n#make subject massage\r\
    \n:local sub (\$name . \" - \" . \$time . \" - \" . \$date);\r\
    \n#make body massage\r\
    \n:local bod (\"See attached file for System Backup\");\r\
    \n#send e-mail\r\
    \n/tool e-mail send to=\"username@gmail.com\" subject=\$sub body=\$bod  server=[:resolve smtp.gmail.com] tls=yes file=([/system identity get name] . \\ \".backup\");\r\
    \n#show info message in log\r\
    \n:log info \"Finish sending e-mail\";\r\
    \n"

I have try as per your suggestion, see the attach file and confirm me is it ok. but mikrotik does not send mail to my mail account.
Doc1.doc (154 KB)

I am sure it will not send you like this…

The script i gave you, is auto generated with export command from terminal.

Remove the last script you add first.
You have to open the terminal and write: system scripts and hit enter and after that copy paste the script in the terminal.

If everything is ok you should see the scripts without the “\n” characters.

After this try to run it again.

If the script run is ok you should see in your log file the line: “Finish sending e-mail”…

If I paste your script in terminal then script name will show in /system/script or NOT ? because I am not exparte with mikrotik

yes

Can I delete this script any time from /system/script
when I wrote system scripts in terminal then firstly use “/” or not

You can’t have two scripts with the same name.

Or you can delete the old one Or you can name the new one with other name (test_email2)…

when I write system scripts in terminal, firstly use “/”. as like /system scripts or NOT