PPP Profile Scripts to send an email

So inside each PPP profile there’s a “On Up” and “On Down” field to write a script.

So I have two ISPs, both PPPoE clients.

So I use the “On Down” field to send an email when the link is down like this:

/tool e-mail send to=example@gmail.com subject="MikroTik" body="ISP2 went down" start-tls=yes

The problem is, it will keep sending the emails times infinity until the link comes back up and fill up my email, any ideas what can I do to make sure it only retries sending the mail if it failed the first n number of times and stop once it’s successfully sent at least once?