mod/notification-email: add display name with identity (if not given)

This commit is contained in:
Christian Hesse 2024-03-12 21:52:18 +01:00
parent 44fc69e82d
commit c016a6ef47

View file

@ -8,6 +8,7 @@
# send notifications via e-mail # send notifications via e-mail
# https://git.eworm.de/cgit/routeros-scripts/about/doc/mod/notification-email.md # https://git.eworm.de/cgit/routeros-scripts/about/doc/mod/notification-email.md
:global EMailGenerateFrom;
:global FlushEmailQueue; :global FlushEmailQueue;
:global LogForwardFilterLogForwarding; :global LogForwardFilterLogForwarding;
:global NotificationEMailSubject; :global NotificationEMailSubject;
@ -17,11 +18,25 @@
:global SendEMail; :global SendEMail;
:global SendEMail2; :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 # flush e-mail queue
:set FlushEmailQueue do={ :set FlushEmailQueue do={
:global EmailQueue; :global EmailQueue;
:global EitherOr; :global EitherOr;
:global EMailGenerateFrom;
:global IsDNSResolving; :global IsDNSResolving;
:global IsTimeSync; :global IsTimeSync;
:global LogPrint; :global LogPrint;
@ -67,8 +82,8 @@
$LogPrint warning $0 ("File '" . $File . "' does not exist, can not attach."); $LogPrint warning $0 ("File '" . $File . "' does not exist, can not attach.");
} }
} }
/tool/e-mail/send to=($Message->"to") cc=($Message->"cc") subject=($Message->"subject") \ /tool/e-mail/send from=[ $EMailGenerateFrom ] to=($Message->"to") cc=($Message->"cc") \
body=($Message->"body") file=$Attach; subject=($Message->"subject") body=($Message->"body") file=$Attach;
:local Wait true; :local Wait true;
:do { :do {
:delay 1s; :delay 1s;