From b3949a8881bf3a5684ffa2fcfc3b49b0ad8372f2 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 16:50:49 +0100 Subject: [PATCH] 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). --- doc/mod/notification-email.md | 2 +- mod/notification-email.rsc | 33 +++++++++------------------------ 2 files changed, 10 insertions(+), 25 deletions(-) diff --git a/doc/mod/notification-email.md b/doc/mod/notification-email.md index c45e917c..bfe1b963 100644 --- a/doc/mod/notification-email.md +++ b/doc/mod/notification-email.md @@ -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 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) -[![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) [![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) diff --git a/mod/notification-email.rsc b/mod/notification-email.rsc index 6b5224ce..3f6bd6fc 100644 --- a/mod/notification-email.rsc +++ b/mod/notification-email.rsc @@ -3,7 +3,7 @@ # Copyright (c) 2013-2026 Christian Hesse # https://rsc.eworm.de/COPYING.md # -# requires RouterOS, version=7.19 +# requires RouterOS, version=7.21 # requires device-mode, email, scheduler # # send notifications via e-mail @@ -91,7 +91,6 @@ :foreach Id,Message in=$EmailQueue do={ :if ([ :typeof $Message ] = "array" ) do={ - :while ([ /tool/e-mail/get last-status ] = "in-progress") do={ :delay 1s; } :onerror Err { :local Attach ({}); :foreach File in=[ :toarray [ $EitherOr ($Message->"attach") "" ] ] do={ @@ -101,29 +100,15 @@ $LogPrint warning $0 ("File '" . $File . "' does not exist, can not attach."); } } - :do { - /tool/e-mail/send from=[ $EMailGenerateFrom ] to=($Message->"to") \ - cc=($Message->"cc") subject=($Message->"subject") \ - body=($Message->"body") file=$Attach; - } on-error={ } - :local Wait true; - :do { - :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; - } - } + /tool/e-mail/send from=[ $EMailGenerateFrom ] to=($Message->"to") \ + cc=($Message->"cc") subject=($Message->"subject") \ + body=($Message->"body") file=$Attach; + :set ($EmailQueue->$Id); + :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={ $LogPrint warning $0 ("Sending queued mail failed: " . $Err); :set AllDone false;