send mail with IP address

Hello
I want to make a script that send me to the mail the IP address that I get from my provider.
I have dynamic IP , so when the RB restart I can’t reach him.

Thanks,

If you are still using Gmail, then these scripts should resolve and set the server ip.

For v4.x

/tool e-mail
set server=([:resolve smtp.gmail.com] . ":587");

For v5.x

/tool e-mail
set address=[:resolve smtp.gmail.com];

edit: Is this what you want, or something else?

I think he wants to mail himself the IP address he got via DHCP client on the router. His ISP hives him dynamic IP address, he doesn’t know it.

OK, I can do that too! :smiley:

:local newIP [/ip address get [find where interface=ether1] address];
:put $newIP;

Test it, then remove the “:put $newIP”. Then send the email with the variable $newIP in it.

Thank you (again)
I have try to this like you did in the gps-txt and got lost.

what else can I add in the script that he would do this every time he connect?
let say that my router is having electricity problem and do reset 6-8 times a day- so he his changing the ip 6-8 times a day.
I want him to send me the IP as-soon as he change it.

I did something like this
if ($myip=$newip) do={beep length=3} else={send E-mail-$newip}

and it’s good (I define newip 5 min after the connection)
is this a good way to do this ? or you would do something else?

Schedule the script to run on startup if that is when you get a new ip. Name the script newip, then schedule it like this.

/system scheduler
add name=newip start-time=startup on-event=newip

You may need to add a delay to the beginning of the newip script to allow the interface to get a new ip before trying to get it.

o.k.
I think I gets it

Thanks

You might want to consider two scripts.

One that runs on startup, sets the myip variable initially, and sends a “reboot” message in the email.
A second script that checks the ip at about half the dhcp lease renewal interval.

That way you will know the difference between a router reboot and a dhcp lease renewal.

yes, this is what I was thinking to do.

Thanks again ,