mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2026-01-20 07:59:33 +00:00
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:
parent
867b4b0067
commit
b3949a8881
2 changed files with 10 additions and 25 deletions
|
|
@ -4,7 +4,7 @@ Send notifications via e-mail
|
|||
[](https://github.com/eworm-de/routeros-scripts/stargazers)
|
||||
[](https://github.com/eworm-de/routeros-scripts/network)
|
||||
[](https://github.com/eworm-de/routeros-scripts/watchers)
|
||||
[](https://mikrotik.com/download/changelogs/)
|
||||
[](https://mikrotik.com/download/changelogs/)
|
||||
[](https://t.me/routeros_scripts)
|
||||
[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=A4ZXBD6YS2W8J)
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
# Copyright (c) 2013-2026 Christian Hesse <mail@eworm.de>
|
||||
# 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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue