mod/notification-email: add setting for certificate verification

This commit is contained in:
Christian Hesse 2026-04-22 11:04:57 +02:00
parent f5dbc27a01
commit 1f460b5bae
5 changed files with 17 additions and 2 deletions

View file

@ -37,7 +37,9 @@ Also make sure the device has correct time configured, best is to set up
the ntp client. the ntp client.
Then edit `global-config-overlay`, add `EmailGeneralTo` with a valid Then edit `global-config-overlay`, add `EmailGeneralTo` with a valid
recipient address. Finally reload the configuration. recipient address. Optionally add `EmailServerCertificate` and add the CA
certificate name if you have certificate verification enabled. Finally
reload the configuration.
> **Info**: Copy relevant configuration from > **Info**: Copy relevant configuration from
> [`global-config`](../../global-config.rsc) (the one without `-overlay`) to > [`global-config`](../../global-config.rsc) (the one without `-overlay`) to

View file

@ -31,6 +31,8 @@
:global EmailGeneralCc ""; :global EmailGeneralCc "";
#:global EmailGeneralTo "mail@example.com"; #:global EmailGeneralTo "mail@example.com";
#:global EmailGeneralCc "another@example.com,third@example.com"; #:global EmailGeneralCc "another@example.com,third@example.com";
# Add the CA certificate name here for verification.
:global EmailServerCertificate "";
# You can send Telegram notifications. Register a bot # You can send Telegram notifications. Register a bot
# and add the token and chat ids here, then install the module: # and add the token and chat ids here, then install the module:

View file

@ -15,7 +15,7 @@
# Git commit id & info, expected configuration version # Git commit id & info, expected configuration version
:global CommitId "unknown"; :global CommitId "unknown";
:global CommitInfo "unknown"; :global CommitInfo "unknown";
:global ExpectedConfigVersion 141; :global ExpectedConfigVersion 142;
# global variables not to be changed by user # global variables not to be changed by user
:global GlobalFunctionsReady false; :global GlobalFunctionsReady false;

View file

@ -37,7 +37,9 @@
# flush e-mail queue # flush e-mail queue
:set FlushEmailQueue do={ :onerror Err { :set FlushEmailQueue do={ :onerror Err {
:global EmailQueue; :global EmailQueue;
:global EmailServerCertificate;
:global CertificateAvailable;
:global EitherOr; :global EitherOr;
:global EMailGenerateFrom; :global EMailGenerateFrom;
:global FileExists; :global FileExists;
@ -90,6 +92,14 @@
:return false; :return false;
} }
:if (([ /tool/e-mail/get ]->"certificate-verification") ~ "^yes" && \
[ :len $EmailServerCertificate ] > 0) do={
:if ([ $CertificateAvailable $EmailServerCertificate "email" ] = false) do={
$LogPrint warning $0 ("Downloading required certificate failed.");
:return false;
}
}
/system/scheduler/set interval=($QueueLen . "m") comment="Sending..." \ /system/scheduler/set interval=($QueueLen . "m") comment="Sending..." \
[ find where name="_FlushEmailQueue" ]; [ find where name="_FlushEmailQueue" ];

View file

@ -66,6 +66,7 @@
139="Certificate Authorities will reduce the leaf certificate validity times soon. Thus the defaults for renewal and warning in 'check-certificates' were decreased."; 139="Certificate Authorities will reduce the leaf certificate validity times soon. Thus the defaults for renewal and warning in 'check-certificates' were decreased.";
140="The scripts 'lease-script' was renamed to 'dhcpv4-server-lease', configuration was updated automatically."; 140="The scripts 'lease-script' was renamed to 'dhcpv4-server-lease', configuration was updated automatically.";
141="Introduced script 'dhcpv6-client-lease' to run several scripts on IPv6 DHCP client lease."; 141="Introduced script 'dhcpv6-client-lease' to run several scripts on IPv6 DHCP client lease.";
142="Added a setting for 'mod/notification-email' to check availability of certificate chain.";
}; };
# Migration steps to be applied on script updates # Migration steps to be applied on script updates