Allow setting of SMTP port

This commit is contained in:
Jamie Cameron
2013-07-14 22:56:32 +08:00
parent dbd3250861
commit c3be4b9c6b
3 changed files with 13 additions and 1 deletions

View File

@@ -20,11 +20,14 @@ print &ui_table_row($text{'sendmail_system'},
$smtp = $mconfig{'send_mode'};
$mode = $smtp eq "" ? 0 :
$smtp eq "localhost" || $smtp eq "127.0.0.1" ? 1 : 2;
$port = ($mode == 2 ? $mconfig{'smtp_port'} : undef) || 25;
print &ui_table_row($text{'sendmail_smtp'},
&ui_radio("mode", $mode, [ [ 0, $text{'sendmail_smtp0'}."<br>" ],
[ 1, $text{'sendmail_smtp1'}."<br>" ],
[ 2, $text{'sendmail_smtp2'} ] ]).
" ".&ui_textbox("smtp", $mode == 2 ? $smtp : "", 40));
" ".&ui_textbox("smtp", $mode == 2 ? $smtp : "", 40).
" ".$text{'sendmail_port'}.
" ".&ui_textbox("port", $port, 6));
# SMTP login and password
$user = $mconfig{'smtp_user'};

View File

@@ -949,6 +949,7 @@ sendmail_desc=This page controls how Webmin sends email, such as from scheduled
sendmail_header=Mail sending options
sendmail_system=Local mail server
sendmail_smtp=Send email using
sendmail_port=on port
sendmail_smtp0=Local mail server command
sendmail_smtp1=Via SMTP to local mail server
sendmail_smtp2=Via SMTP to remote mail server
@@ -962,6 +963,7 @@ sendmail_fromdef=Default ($1)
sendmail_fromaddr=Address
sendmail_err=Failed to save mail sending options
sendmail_esmtp=Missing or un-resolvable SMTP server hostname
sendmail_eport=Missing or non-numeric SMTP port
sendmail_elogin=Missing SMTP server login
sendmail_esasl=SMTP authentication cannot be enabled unless the <a href=$1>$2</a> Perl module is installed.
sendmail_efrom=Missing or incorrectly formatted from address

View File

@@ -19,6 +19,13 @@ else {
&to_ipaddress($in{'smtp'}) || &to_ip6address($in{'smtp'}) ||
&error($text{'sendmail_esmtp'});
$mconfig{'send_mode'} = $in{'smtp'};
$in{'port'} =~ /^\d+$/ || &error($text{'sendmail_eport'});
if ($in{'port'} == 25) {
delete($mconfig{'smtp_port'});
}
else {
$mconfig{'smtp_port'} = $in{'port'};
}
}
# Save login and password