Properly distinguish between global and custom webmin email

https://github.com/webmin/webmin/issues/2295
This commit is contained in:
Jamie Cameron
2025-10-09 21:37:12 -07:00
parent 7e5007e050
commit 360236d68b
3 changed files with 20 additions and 10 deletions

View File

@@ -54,9 +54,17 @@ print &ui_table_row($text{'sched_warn'},
$defmsg = $gconfig{'webmin_email_to'} ?
&text('sched_email_def', "<tt>$gconfig{'webmin_email_to'}</tt>") :
$text{'sched_none'};
my @opts = ( [ 1, $text{'sched_none'} ],
[ 0, &ui_textbox("email", $config{'sched_email'}, 30) ] );
if ($gconfig{'webmin_email_to'}) {
splice(@opts, 1, 0, [ 2, &text('sched_email_def',
"<tt>$gconfig{'webmin_email_to'}</tt>") ]);
}
print &ui_table_row($text{'sched_email'},
&ui_opt_textbox("email", $config{'sched_email'}, 30,
$defmsg, $text{'sched_email'}), 3);
&ui_radio("email_def",
!$config{'sched_email'} ? 1 :
$config{'sched_email'} eq $gconfig{'webmin_email_to'} ? 2 : 0,
\@opts));
# From: address
print &ui_table_row($text{'sched_from'},

View File

@@ -259,14 +259,12 @@ foreach $serv (@services) {
if ($config{'sched_single'} && $email) {
# Force the sending of one email and page per report
print DEBUG " Sending email to ",
($config{'sched_email'} ||
$gconfig{'webmin_email_to'}),"\n";
$config{'sched_email'},"\n";
my $err = &send_status_email(
$email,
$config{'subject_mode'} ? $subj :
&text('monitor_sub', $subj),
$config{'sched_email'} ||
$gconfig{'webmin_email_to'});
$config{'sched_email'});
print DEBUG $err ? " Email failed : $err\n"
: " Done\n";
undef($email);
@@ -330,13 +328,13 @@ foreach $serv (@services) {
# Send the email and page with all messages, if necessary
if ($ecount && !$config{'sched_single'}) {
print DEBUG "Sending email to ",
($config{'sched_email'} || $gconfig{'webmin_email_to'}),"\n";
$config{'sched_email'},"\n";
my $err = &send_status_email(
$email,
$config{'subject_mode'} ? $text{'monitor_sub2'} :
$ecount == 1 ? &text('monitor_sub', $subj) :
&text('monitor_sub3', $ecount),
$config{'sched_email'} || $gconfig{'webmin_email_to'});
$config{'sched_email'});
print DEBUG $err ? "Email failed : $err\n" : "Done\n";
}
if ($pager_msg && !$config{'sched_single'}) {

View File

@@ -8,8 +8,12 @@ $access{'sched'} || &error($text{'sched_ecannot'});
&error_setup($text{'sched_err'});
# Parse and save inputs
$in{'email_def'} || $in{'email'} =~ /\S/ || &error($text{'sched_eemail'});
$config{'sched_email'} = $in{'email_def'} ? '' : $in{'email'};
if ($in{'email_def'} == 1) {
$in{'email'} =~ /\S/ || &error($text{'sched_eemail'});
}
$config{'sched_email'} = $in{'email_def'} == 1 ? '' :
$in{'email_def'} == 2 ? $gconfig{'webmin_email_to'} :
$in{'email'};
if ($config{'pager_cmd'}) {
$config{'sched_pager'} = $in{'pager_def'} ? '' : $in{'pager'};
}