Code: Select all
:do {/tool e-mail send server=1.1.1.1 port=25 user=admin@test.com password=111 start-tls=yes to="111@gmail.com" from=admin@test.com subject="555" body="sdg"} on-error={ :log info "hh"}
:do {/tool e-mail send server=1.1.1.1 port=25 user=admin@test.com password=111 start-tls=yes to="111@gmail.com" from=admin@test.com subject="555" body="sdg"} on-error={ :log info "hh"}
Hello,
E-mail tool already writes in Log errors about unsuccessful mail deliveries. For example:
11:52:05 system,e-mail,error Error sending e-mail <555>: timeout occurred
E-mail tool itself does not return error in CLI and works in background. On-error is not solution for e-mail tool.
Best regards,
Martins S.
:global RES
:set RES [/tool e-mail send to="..." body="..." subject="..."]
{
:local RES 1;
:do {
:do { ... send an e-mail ..... } on-error={ :log info "!Error sending an e-mail"; :set RES 0; }
} while( RES = 0 )
}
{
:local RES 1;
:do {
:do {
:log info "Sending an email...";
/tool e-mail send ... ;
:log info "Email sent.";
} on-error={
:log info "!Error sending an e-mail";
:set RES 0;
}
} while (RES = 0)
:log info "Over.";
}
[admin@stationDude] > :global mailStatus [/tool e-mail get last-status]
[admin@stationDude] > :put $mailStatus
succeeded
:local attempts 0;
do {
:set attempts ($attempts+1);
:if ($attempts > 1) do {:log info ("ERROR - last email status: ".[/tool e-mail get last-status];); :delay 2s;}
/tool e-mail send ... ;
do {:delay 200ms;} while ([/tool e-mail get last-status] = "in-progress")
} while ($attempts < 5 and [/tool e-mail get last-status] != "succeeded")