Merge branch 'dk/send-email-avoid-net-smtp-ssl-when-able'
"git send-email" now uses Net::SMTP::SSL, which is obsolete, only when needed. Recent versions of Net::SMTP can do TLS natively. * dk/send-email-avoid-net-smtp-ssl-when-able: send-email: Net::SMTP::SSL is obsolete, use only when necessary
This commit is contained in:
commit
663bf0439e
@ -1354,10 +1354,12 @@ EOF
|
|||||||
die __("The required SMTP server is not properly defined.")
|
die __("The required SMTP server is not properly defined.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
require Net::SMTP;
|
||||||
|
my $use_net_smtp_ssl = version->parse($Net::SMTP::VERSION) < version->parse("1.28");
|
||||||
|
$smtp_domain ||= maildomain();
|
||||||
|
|
||||||
if ($smtp_encryption eq 'ssl') {
|
if ($smtp_encryption eq 'ssl') {
|
||||||
$smtp_server_port ||= 465; # ssmtp
|
$smtp_server_port ||= 465; # ssmtp
|
||||||
require Net::SMTP::SSL;
|
|
||||||
$smtp_domain ||= maildomain();
|
|
||||||
require IO::Socket::SSL;
|
require IO::Socket::SSL;
|
||||||
|
|
||||||
# Suppress "variable accessed once" warning.
|
# Suppress "variable accessed once" warning.
|
||||||
@ -1369,34 +1371,48 @@ EOF
|
|||||||
# Net::SMTP::SSL->new() does not forward any SSL options
|
# Net::SMTP::SSL->new() does not forward any SSL options
|
||||||
IO::Socket::SSL::set_client_defaults(
|
IO::Socket::SSL::set_client_defaults(
|
||||||
ssl_verify_params());
|
ssl_verify_params());
|
||||||
$smtp ||= Net::SMTP::SSL->new($smtp_server,
|
|
||||||
Hello => $smtp_domain,
|
if ($use_net_smtp_ssl) {
|
||||||
Port => $smtp_server_port,
|
require Net::SMTP::SSL;
|
||||||
Debug => $debug_net_smtp);
|
$smtp ||= Net::SMTP::SSL->new($smtp_server,
|
||||||
|
Hello => $smtp_domain,
|
||||||
|
Port => $smtp_server_port,
|
||||||
|
Debug => $debug_net_smtp);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$smtp ||= Net::SMTP->new($smtp_server,
|
||||||
|
Hello => $smtp_domain,
|
||||||
|
Port => $smtp_server_port,
|
||||||
|
Debug => $debug_net_smtp,
|
||||||
|
SSL => 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
require Net::SMTP;
|
|
||||||
$smtp_domain ||= maildomain();
|
|
||||||
$smtp_server_port ||= 25;
|
$smtp_server_port ||= 25;
|
||||||
$smtp ||= Net::SMTP->new($smtp_server,
|
$smtp ||= Net::SMTP->new($smtp_server,
|
||||||
Hello => $smtp_domain,
|
Hello => $smtp_domain,
|
||||||
Debug => $debug_net_smtp,
|
Debug => $debug_net_smtp,
|
||||||
Port => $smtp_server_port);
|
Port => $smtp_server_port);
|
||||||
if ($smtp_encryption eq 'tls' && $smtp) {
|
if ($smtp_encryption eq 'tls' && $smtp) {
|
||||||
require Net::SMTP::SSL;
|
if ($use_net_smtp_ssl) {
|
||||||
$smtp->command('STARTTLS');
|
$smtp->command('STARTTLS');
|
||||||
$smtp->response();
|
$smtp->response();
|
||||||
if ($smtp->code == 220) {
|
if ($smtp->code != 220) {
|
||||||
|
die sprintf(__("Server does not support STARTTLS! %s"), $smtp->message);
|
||||||
|
}
|
||||||
|
require Net::SMTP::SSL;
|
||||||
$smtp = Net::SMTP::SSL->start_SSL($smtp,
|
$smtp = Net::SMTP::SSL->start_SSL($smtp,
|
||||||
ssl_verify_params())
|
ssl_verify_params())
|
||||||
or die "STARTTLS failed! ".IO::Socket::SSL::errstr();
|
or die sprintf(__("STARTTLS failed! %s"), IO::Socket::SSL::errstr());
|
||||||
$smtp_encryption = '';
|
|
||||||
# Send EHLO again to receive fresh
|
|
||||||
# supported commands
|
|
||||||
$smtp->hello($smtp_domain);
|
|
||||||
} else {
|
|
||||||
die sprintf(__("Server does not support STARTTLS! %s"), $smtp->message);
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
$smtp->starttls(ssl_verify_params())
|
||||||
|
or die sprintf(__("STARTTLS failed! %s"), IO::Socket::SSL::errstr());
|
||||||
|
}
|
||||||
|
$smtp_encryption = '';
|
||||||
|
# Send EHLO again to receive fresh
|
||||||
|
# supported commands
|
||||||
|
$smtp->hello($smtp_domain);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user