Update Static DNS Entries Every 10 Minutes - MikroTik Script RouterOS

Add a script named SMTP-Updater containting the following code:

:log info "Updating SMTP Address"

:local latestsmtp
:set latestsmtp [:resolve smtp.YOURUPSTREAMISP.com]
:log error "Latest SMTP Address is :$latestsmtp"
:local testingsmtp

/ip dns static
#:log info "Latest SMTP Server Address is: $latestsmtp"

# Starting Loop Below:

:foreach i 

# Add your local static DNS entries below:
in=smtp.itblanket.net,smtp.saix.net,smtp.afrihost.co.za,smtp.afrihost.com do={

:set testingsmtp $i

#:log info "Testing this SMTP: $testingsmtp"
:if ([:len [/ip dns static find name=$testingsmtp]] >0 ) do={

#:log info "Entry exists, updating DNS"
/ip dns static set [find name=$testingsmtp] address=$latestsmtp ttl=600 ;

} else={
#:log info "Entry does not exist, creating the entry"
/ip dns static add name=$testingsmtp address=$latestsmtp ttl=600 ;

};

}
#Loop ends above


#:log info "Latest SMTP: $latestsmtp"
:log info "Static SMTP DNS has been updated"
Now schedule it to run eg every 10 minutes.

Regards, G

Credit: wiki.mikrotik.com