Send email when failover link is active

I have a CCR setup with dual wan failover like in this link: http://www.jpudasaini.com.np/2013/05/simple-failover-mikrotik.html
Both connections are DHCP clients to the different ISPs. It works well but I would like to get an email when the secondary link becomes active.
Is there a script I can use to accomplish this? I am able to send a test email but I have no idea how to automate this to happen when the primary link fails or the secondary starts. Any help would be great.

Anyone?