Netwatch DNS Resolution

I use netwatch all the time. Thing is i need it to test dns resultion as well as ping response and email me if dns resolution fails.

Such as ping every 5 minutes: mail.somedomainorother.com and email me if it fails to resolve. Is there way to do that?

I use this to check a DNS server and change mikrotik’s DNS server if it fails

:local PrimaryDNS "1.2.3.4";
:local BackupDNS "9.9.9.9,149.112.112.112";
:local TestDomain "google.com";

:local ConfiguredDNS [/ip dns get servers];

:if ($ConfiguredDNS = $PrimaryDNS) do={
:do {:put [:resolve $TestDomain server $PrimaryDNS];} on-error={log warning "Primary DNS $PrimaryDNS query failed. Setting $BackupDNS as DNS server";/ip dns set servers=$BackupDNS;}
} else={
:do {:put [:resolve $TestDomain server $PrimaryDNS]; log warning "Primary DNS $PrimaryDNS is back online. Setting $PrimaryDNS as DNS server";/ip dns set servers=$PrimaryDNS;} on-error={ }
}

You can change it to suit your needs.
Change PrimaryDNS with your DNS server.