aboutsummaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2024-03-12 21:52:18 +0100
committerGravatar Christian Hesse <mail@eworm.de>2024-03-12 22:36:29 +0100
commitc016a6ef47eb08ad0f1f72968348af7bfa0acad0 (patch)
tree83449f67b2e1a9ede50653a4c48631d818abb83f /mod
parent44fc69e82d1a612ad276998377b1c3f34310422e (diff)
mod/notification-email: add display name with identity (if not given)
Diffstat (limited to 'mod')
-rw-r--r--mod/notification-email.rsc19
1 files changed, 17 insertions, 2 deletions
diff --git a/mod/notification-email.rsc b/mod/notification-email.rsc
index 78192f3..d801d78 100644
--- a/mod/notification-email.rsc
+++ b/mod/notification-email.rsc
@@ -8,6 +8,7 @@
# send notifications via e-mail
# https://git.eworm.de/cgit/routeros-scripts/about/doc/mod/notification-email.md
+:global EMailGenerateFrom;
:global FlushEmailQueue;
:global LogForwardFilterLogForwarding;
:global NotificationEMailSubject;
@@ -17,11 +18,25 @@
:global SendEMail;
:global SendEMail2;
+# generate from-property with display name
+:set EMailGenerateFrom do={
+ :global Identity;
+
+ :local From [ /tool/e-mail/get from ];
+
+ :if ($From ~ "<.*>\$") do={
+ :return $From;
+ }
+
+ :return ("\"" . $Identity . " via routeros-scripts\" <" . $From . ">");
+}
+
# flush e-mail queue
:set FlushEmailQueue do={
:global EmailQueue;
:global EitherOr;
+ :global EMailGenerateFrom;
:global IsDNSResolving;
:global IsTimeSync;
:global LogPrint;
@@ -67,8 +82,8 @@
$LogPrint warning $0 ("File '" . $File . "' does not exist, can not attach.");
}
}
- /tool/e-mail/send to=($Message->"to") cc=($Message->"cc") subject=($Message->"subject") \
- body=($Message->"body") file=$Attach;
+ /tool/e-mail/send from=[ $EMailGenerateFrom ] to=($Message->"to") cc=($Message->"cc") \
+ subject=($Message->"subject") body=($Message->"body") file=$Attach;
:local Wait true;
:do {
:delay 1s;