mod/notification-email: use errors from command...

... instead of reading status from properties. This was introduced in
RouterOS 7.21beta2 (and we bump to 7.21 instead).
This commit is contained in:
Christian Hesse 2026-01-19 16:50:49 +01:00
parent 867b4b0067
commit b3949a8881
2 changed files with 10 additions and 25 deletions

View file

@ -4,7 +4,7 @@ Send notifications via e-mail
[![GitHub stars](https://img.shields.io/github/stars/eworm-de/routeros-scripts?logo=GitHub&style=flat&color=red)](https://github.com/eworm-de/routeros-scripts/stargazers) [![GitHub stars](https://img.shields.io/github/stars/eworm-de/routeros-scripts?logo=GitHub&style=flat&color=red)](https://github.com/eworm-de/routeros-scripts/stargazers)
[![GitHub forks](https://img.shields.io/github/forks/eworm-de/routeros-scripts?logo=GitHub&style=flat&color=green)](https://github.com/eworm-de/routeros-scripts/network) [![GitHub forks](https://img.shields.io/github/forks/eworm-de/routeros-scripts?logo=GitHub&style=flat&color=green)](https://github.com/eworm-de/routeros-scripts/network)
[![GitHub watchers](https://img.shields.io/github/watchers/eworm-de/routeros-scripts?logo=GitHub&style=flat&color=blue)](https://github.com/eworm-de/routeros-scripts/watchers) [![GitHub watchers](https://img.shields.io/github/watchers/eworm-de/routeros-scripts?logo=GitHub&style=flat&color=blue)](https://github.com/eworm-de/routeros-scripts/watchers)
[![required RouterOS version](https://img.shields.io/badge/RouterOS-7.19-yellow?style=flat)](https://mikrotik.com/download/changelogs/) [![required RouterOS version](https://img.shields.io/badge/RouterOS-7.21-yellow?style=flat)](https://mikrotik.com/download/changelogs/)
[![Telegram group @routeros_scripts](https://img.shields.io/badge/Telegram-%40routeros__scripts-%2326A5E4?logo=telegram&style=flat)](https://t.me/routeros_scripts) [![Telegram group @routeros_scripts](https://img.shields.io/badge/Telegram-%40routeros__scripts-%2326A5E4?logo=telegram&style=flat)](https://t.me/routeros_scripts)
[![donate with PayPal](https://img.shields.io/badge/Like_it%3F-Donate!-orange?logo=githubsponsors&logoColor=orange&style=flat)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=A4ZXBD6YS2W8J) [![donate with PayPal](https://img.shields.io/badge/Like_it%3F-Donate!-orange?logo=githubsponsors&logoColor=orange&style=flat)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=A4ZXBD6YS2W8J)

View file

@ -3,7 +3,7 @@
# Copyright (c) 2013-2026 Christian Hesse <mail@eworm.de> # Copyright (c) 2013-2026 Christian Hesse <mail@eworm.de>
# https://rsc.eworm.de/COPYING.md # https://rsc.eworm.de/COPYING.md
# #
# requires RouterOS, version=7.19 # requires RouterOS, version=7.21
# requires device-mode, email, scheduler # requires device-mode, email, scheduler
# #
# send notifications via e-mail # send notifications via e-mail
@ -91,7 +91,6 @@
:foreach Id,Message in=$EmailQueue do={ :foreach Id,Message in=$EmailQueue do={
:if ([ :typeof $Message ] = "array" ) do={ :if ([ :typeof $Message ] = "array" ) do={
:while ([ /tool/e-mail/get last-status ] = "in-progress") do={ :delay 1s; }
:onerror Err { :onerror Err {
:local Attach ({}); :local Attach ({});
:foreach File in=[ :toarray [ $EitherOr ($Message->"attach") "" ] ] do={ :foreach File in=[ :toarray [ $EitherOr ($Message->"attach") "" ] ] do={
@ -101,29 +100,15 @@
$LogPrint warning $0 ("File '" . $File . "' does not exist, can not attach."); $LogPrint warning $0 ("File '" . $File . "' does not exist, can not attach.");
} }
} }
:do { /tool/e-mail/send from=[ $EMailGenerateFrom ] to=($Message->"to") \
/tool/e-mail/send from=[ $EMailGenerateFrom ] to=($Message->"to") \ cc=($Message->"cc") subject=($Message->"subject") \
cc=($Message->"cc") subject=($Message->"subject") \ body=($Message->"body") file=$Attach;
body=($Message->"body") file=$Attach; :set ($EmailQueue->$Id);
} on-error={ } :if (($Message->"remove-attach") = true) do={
:local Wait true; :foreach File in=$Attach do={
:do { $RmFile $File;
:delay 1s;
:local Status [ /tool/e-mail/get last-status ];
:if ($Status = "succeeded") do={
:set ($EmailQueue->$Id);
:set Wait false;
:if (($Message->"remove-attach") = true) do={
:foreach File in=$Attach do={
$RmFile $File;
}
}
} }
:if ($Status = "failed") do={ }
:set AllDone false;
:set Wait false;
}
} while=($Wait = true);
} do={ } do={
$LogPrint warning $0 ("Sending queued mail failed: " . $Err); $LogPrint warning $0 ("Sending queued mail failed: " . $Err);
:set AllDone false; :set AllDone false;