@@ -1353,10 +1353,12 @@ sub send_message {
1353
1353
die __(" The required SMTP server is not properly defined." )
1354
1354
}
1355
1355
1356
+ require Net::SMTP;
1357
+ my $use_net_smtp_ssl = version-> parse($Net::SMTP::VERSION ) < version-> parse(" 2.34" );
1358
+ $smtp_domain ||= maildomain();
1359
+
1356
1360
if ($smtp_encryption eq ' ssl' ) {
1357
1361
$smtp_server_port ||= 465; # ssmtp
1358
- require Net::SMTP::SSL;
1359
- $smtp_domain ||= maildomain();
1360
1362
require IO::Socket::SSL;
1361
1363
1362
1364
# Suppress "variable accessed once" warning.
@@ -1368,34 +1370,48 @@ sub send_message {
1368
1370
# Net::SMTP::SSL->new() does not forward any SSL options
1369
1371
IO::Socket::SSL::set_client_defaults(
1370
1372
ssl_verify_params());
1371
- $smtp ||= Net::SMTP::SSL-> new($smtp_server ,
1372
- Hello => $smtp_domain ,
1373
- Port => $smtp_server_port ,
1374
- Debug => $debug_net_smtp );
1373
+
1374
+ if ($use_net_smtp_ssl ) {
1375
+ require Net::SMTP::SSL;
1376
+ $smtp ||= Net::SMTP::SSL-> new($smtp_server ,
1377
+ Hello => $smtp_domain ,
1378
+ Port => $smtp_server_port ,
1379
+ Debug => $debug_net_smtp );
1380
+ }
1381
+ else {
1382
+ $smtp ||= Net::SMTP-> new($smtp_server ,
1383
+ Hello => $smtp_domain ,
1384
+ Port => $smtp_server_port ,
1385
+ Debug => $debug_net_smtp ,
1386
+ SSL => 1);
1387
+ }
1375
1388
}
1376
1389
else {
1377
- require Net::SMTP;
1378
- $smtp_domain ||= maildomain();
1379
1390
$smtp_server_port ||= 25;
1380
1391
$smtp ||= Net::SMTP-> new($smtp_server ,
1381
1392
Hello => $smtp_domain ,
1382
1393
Debug => $debug_net_smtp ,
1383
1394
Port => $smtp_server_port );
1384
1395
if ($smtp_encryption eq ' tls' && $smtp ) {
1385
- require Net::SMTP::SSL;
1386
- $smtp -> command(' STARTTLS' );
1387
- $smtp -> response();
1388
- if ($smtp -> code == 220) {
1396
+ if ($use_net_smtp_ssl ) {
1397
+ $smtp -> command(' STARTTLS' );
1398
+ $smtp -> response();
1399
+ if ($smtp -> code != 220) {
1400
+ die sprintf (__(" Server does not support STARTTLS! %s " ), $smtp -> message);
1401
+ }
1402
+ require Net::SMTP::SSL;
1389
1403
$smtp = Net::SMTP::SSL-> start_SSL($smtp ,
1390
1404
ssl_verify_params())
1391
- or die " STARTTLS failed! " .IO::Socket::SSL::errstr();
1392
- $smtp_encryption = ' ' ;
1393
- # Send EHLO again to receive fresh
1394
- # supported commands
1395
- $smtp -> hello($smtp_domain );
1396
- } else {
1397
- die sprintf (__(" Server does not support STARTTLS! %s " ), $smtp -> message);
1405
+ or die sprintf (__(" STARTTLS failed! %s " ), IO::Socket::SSL::errstr());
1406
+ }
1407
+ else {
1408
+ $smtp -> starttls(ssl_verify_params())
1409
+ or die sprintf (__(" STARTTLS failed! %s " ), IO::Socket::SSL::errstr());
1398
1410
}
1411
+ $smtp_encryption = ' ' ;
1412
+ # Send EHLO again to receive fresh
1413
+ # supported commands
1414
+ $smtp -> hello($smtp_domain );
1399
1415
}
1400
1416
}
1401
1417
0 commit comments