Learn the script execution status, example:
Code: Select all
/tool e-mail send to=exemple@mail.ru subject="Mikrotik" body=hello
:if (email send....) do=
/tool e-mail send to=exemple@mail.ru subject="Mikrotik" body=hello
:if (email send....) do=
:if ([ /tool e-mail get last-status ] = "succeeded") do={ ...
{
# Wait until other script in bg end sending e-mail now...
while ([tool e-mail get last-status] = "in-progress") do={delay 1s}
delay 2s
# Now I send my e-mail who has wrong smtp server and reach timeout...
tool e-mail send server=1.1.1.1 subject="WrongSMTP" to=name@domain.tld
while ([tool e-mail get last-status] = "in-progress") do={delay 1s}
local EMailStatus [tool e-mail get last-status]
if ($EMailStatus = "failed") do={put "ERROR"}
if ($EMailStatus = "succeeded") do={put "SUCCESS"}
}
{
tool e-mail send server=1.1.1.1 subject="WrongSMTP" to=name@domain.tld
local ExitDoLoop false
while ($ExitDoLoop = false) do={
local EMailStatus [tool e-mail get last-status];
if ($EMailStatus = "in-progress") do={delay 1s; put "."} else={
set $ExitDoLoop true;
if ($EMailStatus = "failed") do={put "ERROR"}
if ($EMailStatus = "succeeded") do={put "SUCCESS"}
}
}
}
:do { :delay 1s } while=( [/tool e-mail get last-status] = "in-progress" )