mirror of
https://git.eworm.de/cgit/routeros-scripts
synced 2025-07-16 04:54:28 +02:00
mod/notification-email: properly truncate the body
Truned out that the size limit for e-mail message/body is anywhere just below 64kB... So truncate at about 62.000 bytes.
This commit is contained in:
parent
ff218e4ce5
commit
74dc809b98
1 changed files with 13 additions and 3 deletions
|
@ -181,6 +181,7 @@
|
|||
:global IfThenElse;
|
||||
:global NotificationEMailSignature;
|
||||
:global NotificationEMailSubject;
|
||||
:global SymbolForNotification;
|
||||
|
||||
:local To [ $EitherOr ($EmailGeneralToOverride->($Notification->"origin")) $EmailGeneralTo ];
|
||||
:local Cc [ $EitherOr ($EmailGeneralCcOverride->($Notification->"origin")) $EmailGeneralCc ];
|
||||
|
@ -193,13 +194,22 @@
|
|||
:if ([ :typeof $EmailQueue ] = "nothing") do={
|
||||
:set EmailQueue ({});
|
||||
}
|
||||
:local Truncated false;
|
||||
:local Body ($Notification->"message");
|
||||
:if ([ :len $Body ] > 62000) do={
|
||||
:set Body ([ :pick $Body 0 62000 ] . "...");
|
||||
:set Truncated true;
|
||||
}
|
||||
:local Signature [ $EitherOr [ $NotificationEMailSignature ] [ /system/note/get note ] ];
|
||||
:set Body ($Body . "\n" . \
|
||||
[ $IfThenElse ([ :len ($Notification->"link") ] > 0) ("\n" . ($Notification->"link")) ] . \
|
||||
[ $IfThenElse ($Truncated = true) ("\n" . [ $SymbolForNotification "scissors" ] . \
|
||||
"The message was too long and has been truncated!") ] . \
|
||||
[ $IfThenElse ([ :len $Signature ] > 0) ("\n-- \n" . $Signature) "" ]);
|
||||
:set ($EmailQueue->[ :len $EmailQueue ]) {
|
||||
to=$To; cc=$Cc;
|
||||
subject=[ $NotificationEMailSubject ($Notification->"subject") ];
|
||||
body=(($Notification->"message") . \
|
||||
[ $IfThenElse ([ :len ($Notification->"link") ] > 0) ("\n\n" . ($Notification->"link")) "" ] . \
|
||||
[ $IfThenElse ([ :len $Signature ] > 0) ("\n-- \n" . $Signature) "" ]); \
|
||||
body=$Body; \
|
||||
attach=($Notification->"attach"); remove-attach=($Notification->"remove-attach") };
|
||||
:if ([ :len [ /system/scheduler/find where name="_FlushEmailQueue" ] ] = 0) do={
|
||||
/system/scheduler/add name="_FlushEmailQueue" interval=1s start-time=startup \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue