Send email of my IP address

Hello,

I am newbie to RouterOS and I am trying to set my router to send the external ip of my Internet connection, when it is changed.

I created a script “send_ip” using the code from here “Sending your self an e-mail with DSL interface IP address
:global ddnsip
:global ddnslastip
:if ([ :typeof $ddnslastip ] = nil ) do={ :global ddnslastip “0” }
:global ddnsinterface
:global ddnssystem (“Version-” . [/system package get system version] )
:local int
:foreach int in=[/ip route find dst-address=0.0.0.0/0 active=yes ] do={
:if ([:typeof [/ip route get $int routing-mark ]] != str ) do={
:global ddnsinterface [/ip route get $int interface]
}
}
:global ddnsip [ /ip address get [/ip address find interface=$ddnsinterface ] address ]
:if ([ :typeof $ddnsip ] = nil ) do={
:log info ("DDNS: No ip address present on " . $ddnsinterface . “, please check.”)
} else={
:if ($ddnsip != $ddnslastip) do={
:global strDate [/system clock get date]
:global strTime [/system clock get time]
:global strSystemName [/system identity get name]
/tool e-mail send from=myemail@gmail.com to=myemail@gmail.com subject=“DSL IP $strDate $strTime $strSystemName” body=“DSL IP $ddnsip” server=mail_server_ip_address
:log info “DDNS: Sending UPDATE!”
:global ddnslastip “$ddnsip”
} else={
}
}I tried to test it, click on Run Script but I didn’t receive any email. The email settings have been configured correctly.
The version of my router is 6.44

What I am missing? :neutral_face:

Thanks a lot

Have you tried IP->Cloud? A free dynamic DNS from Mikrotik.

Here is how to get public IP:

:put [/ip address get [find interface=[/ip route get [find dst-address=0.0.0.0/0] vrf-interface]] address]

To store it to an variable.

:local pubIP [/ip address get [find interface=[/ip route get [find dst-address=0.0.0.0/0] vrf-interface]] address]