Add UI option to control when update email is sent

https://github.com/webmin/webmin/issues/2726
This commit is contained in:
Jamie Cameron
2026-05-24 13:08:58 -07:00
parent 93befb0a1a
commit 6f4f85d33c
4 changed files with 17 additions and 1 deletions

View File

@@ -220,6 +220,13 @@ else {
}
print &ui_table_row($text{'index_email'}, $efield);
# When to send email
print &ui_table_row($text{'index_ewhen'},
&ui_radio("when", int($config{'sched_when'}),
[ [ 0, $text{'index_ewhen0'} ],
[ 1, $text{'index_ewhen1'} ],
[ 2, $text{'index_ewhen2'} ] ]));
# Install or just notify?
$action_ui = &ui_select("action", int($config{'sched_action'}),
[ [ -1, $text{'index_action-1'} ],

View File

@@ -19,6 +19,10 @@ index_schedd=day
index_schedw=week
index_email=Email updates report to
index_email_def=Webmin default ($1)
index_ewhen=Send email when
index_ewhen0=Any update is installed
index_ewhen1=Any update failed
index_ewhen2=Never (but still install updates)
index_action=Action when update needed
index_action-1=Just notify for security updates
index_action0=Just notify for any updates

View File

@@ -6,6 +6,7 @@ require './package-updates-lib.pl';
&lock_file($module_config_file);
$config{'sched_email'} = $in{'email_def'} ? '*' : $in{'email'};
$config{'sched_when'} = $in{'when'};
$config{'sched_action'} = $in{'action'};
&save_module_config();
&unlock_file($module_config_file);

View File

@@ -33,6 +33,7 @@ else {
}
&start_update_progress([ map { $_->{'name'} } @todo ]);
$icount = 0;
$fcount = 0;
foreach $t (@todo) {
next if ($already{$t->{'update'}});
my $umsg = $t->{'security'} ? "security update" : "update";
@@ -57,6 +58,7 @@ foreach $t (@todo) {
$body .= "However, this $umsg could not be installed! ".
"Try the update manually\nusing the Package ".
"Updates module.\n\n";
$fcount++;
}
foreach $p (@$done) {
$already{$p}++;
@@ -89,7 +91,9 @@ if ($tellcount) {
# Email the admin
$emailto = $config{'sched_email'} eq '*' ? $gconfig{'webmin_email_to'}
: $config{'sched_email'};
if ($emailto && $body) {
if ($emailto && $body &&
($config{'sched_when'} == 0 ||
$config{'sched_when'} == 1 && $fcount)) {
&foreign_require("mailboxes", "mailboxes-lib.pl");
my $from = &mailboxes::get_from_address();
my $mail = { 'headers' =>