mirror of
https://github.com/webmin/webmin.git
synced 2026-03-20 08:40:24 +00:00
UI option to set a custom URL for use in emails
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -11202,6 +11202,38 @@ $referer =~ s/\/\//\//g;
|
||||
return $referer;
|
||||
}
|
||||
|
||||
=head2 get_webmin_email_url([module], [cgi], [force-default])
|
||||
|
||||
Returns the base URL for accessing this Webmin system, for use in URLs.
|
||||
|
||||
=cut
|
||||
sub get_webmin_email_url
|
||||
{
|
||||
my ($mod, $cgi, $def) = @_;
|
||||
|
||||
# Work out the base URL
|
||||
my $url;
|
||||
if (!$def && $gconfig{'webmin_email_url'}) {
|
||||
$url = $gconfig{'webmin_email_url'};
|
||||
}
|
||||
else {
|
||||
my %miniserv;
|
||||
&get_miniserv_config(\%miniserv);
|
||||
my $proto = $miniserv{'ssl'} ? 'https' : 'http';
|
||||
my $port = $miniserv{'port'};
|
||||
my $host = &get_system_hostname();
|
||||
my $defport = $proto eq 'https' ? 443 : 80;
|
||||
$url = $proto."://".$host.($port == $defport ? "" : ":".$port);
|
||||
$url .= $gconfig{'webprefix'} if ($gconfig{'webprefix'});
|
||||
}
|
||||
|
||||
# Append module if needed
|
||||
$url =~ s/\/$//;
|
||||
$url .= "/".$mod if ($mod);
|
||||
$url .= "/".$cgi if ($cgi);
|
||||
return $url;
|
||||
}
|
||||
|
||||
$done_web_lib_funcs = 1;
|
||||
|
||||
1;
|
||||
|
||||
@@ -67,6 +67,14 @@ print &ui_table_row($text{'sendmail_from'},
|
||||
&text('sendmail_fromdef', $fromdef)."<br>",
|
||||
$text{'sendmail_fromaddr'}));
|
||||
|
||||
# URL for use in emails
|
||||
$url = $gconfig{'webmin_email_url'};
|
||||
$defurl = &get_webmin_email_url(undef, undef, 1);
|
||||
print &ui_table_row($text{'sendmail_url'},
|
||||
&ui_opt_textbox("url", $url, 40,
|
||||
&text('sendmail_url_def', "<tt>$defurl</tt>")."<br>",
|
||||
$text{'sendmail_url_custom'}));
|
||||
|
||||
print &ui_table_end();
|
||||
print &ui_form_end([ [ "", $text{'save'} ] ]);
|
||||
|
||||
|
||||
@@ -1042,6 +1042,10 @@ sendmail_subject=Message subject
|
||||
sendmail_body=Message contents
|
||||
sendmail_desc2=This form can be used to send a test email with the settings above, to ensure that mail is being delivered correctly.
|
||||
sendmail_send=Send Email
|
||||
sendmail_url=Webmin URL for use in email
|
||||
sendmail_url_def=Default ($1)
|
||||
sendmail_url_custom=Custom URL
|
||||
sendmail_eurl=Missing or invalid custom URL
|
||||
|
||||
testmail_title=Send Test Email
|
||||
testmail_err=Failed to send test message
|
||||
|
||||
@@ -6,6 +6,7 @@ require './webmin-lib.pl';
|
||||
&error_setup($text{'sendmail_err'});
|
||||
&foreign_require("mailboxes");
|
||||
&lock_file($mailboxes::module_config_file);
|
||||
&lock_file("$config_directory/config");
|
||||
%mconfig = &foreign_config("mailboxes");
|
||||
|
||||
# Save smtp server
|
||||
@@ -63,8 +64,20 @@ else {
|
||||
$mconfig{'webmin_from'} = $in{'from'};
|
||||
}
|
||||
|
||||
# Save URL for use in email
|
||||
if ($in{'url_def'}) {
|
||||
delete($gconfig{'webmin_email_url'});
|
||||
}
|
||||
else {
|
||||
my @p = &parse_http_url($in{'url'});
|
||||
$p[0] || &error($text{'sendmail_eurl'});
|
||||
$gconfig{'webmin_email_url'} = $in{'url'};
|
||||
}
|
||||
|
||||
&save_module_config(\%mconfig, "mailboxes");
|
||||
&write_file("$config_directory/config", \%gconfig);
|
||||
&unlock_file("$config_directory/config");
|
||||
&unlock_file($mailboxes::module_config_file);
|
||||
&webmin_log("sendmail");
|
||||
&redirect("edit_sendmail.cgi");
|
||||
&redirect("");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user