Line 0
Link Here
|
|
|
1 |
Refactor send_message() to remove dependency on deprecated |
2 |
Net::SMTP::SSL: |
3 |
|
4 |
<http://search.cpan.org/~rjbs/Net-SMTP-SSL-1.04/lib/Net/SMTP/SSL.pm#DEPRECATED> |
5 |
|
6 |
Signed-off-by: Mike Fisher <mfisher@csh.rit.edu> |
7 |
--- git-send-email.perl.orig 2016-11-29 21:06:51 UTC |
8 |
+++ git-send-email.perl |
9 |
@@ -1335,10 +1335,13 @@ Message-Id: $message_id |
10 |
die "The required SMTP server is not properly defined." |
11 |
} |
12 |
|
13 |
+ require Net::SMTP; |
14 |
+ $smtp_domain ||= maildomain(); |
15 |
+ my $smtp_ssl = 0; |
16 |
+ |
17 |
if ($smtp_encryption eq 'ssl') { |
18 |
$smtp_server_port ||= 465; # ssmtp |
19 |
- require Net::SMTP::SSL; |
20 |
- $smtp_domain ||= maildomain(); |
21 |
+ $smtp_ssl = 1; |
22 |
require IO::Socket::SSL; |
23 |
|
24 |
# Suppress "variable accessed once" warning. |
25 |
@@ -1347,37 +1350,31 @@ Message-Id: $message_id |
26 |
$IO::Socket::SSL::DEBUG = 1; |
27 |
} |
28 |
|
29 |
- # Net::SMTP::SSL->new() does not forward any SSL options |
30 |
IO::Socket::SSL::set_client_defaults( |
31 |
ssl_verify_params()); |
32 |
- $smtp ||= Net::SMTP::SSL->new($smtp_server, |
33 |
- Hello => $smtp_domain, |
34 |
- Port => $smtp_server_port, |
35 |
- Debug => $debug_net_smtp); |
36 |
} |
37 |
else { |
38 |
- require Net::SMTP; |
39 |
- $smtp_domain ||= maildomain(); |
40 |
$smtp_server_port ||= 25; |
41 |
- $smtp ||= Net::SMTP->new($smtp_server, |
42 |
- Hello => $smtp_domain, |
43 |
- Debug => $debug_net_smtp, |
44 |
- Port => $smtp_server_port); |
45 |
- if ($smtp_encryption eq 'tls' && $smtp) { |
46 |
- require Net::SMTP::SSL; |
47 |
- $smtp->command('STARTTLS'); |
48 |
- $smtp->response(); |
49 |
- if ($smtp->code == 220) { |
50 |
- $smtp = Net::SMTP::SSL->start_SSL($smtp, |
51 |
- ssl_verify_params()) |
52 |
- or die "STARTTLS failed! ".IO::Socket::SSL::errstr(); |
53 |
- $smtp_encryption = ''; |
54 |
- # Send EHLO again to receive fresh |
55 |
- # supported commands |
56 |
- $smtp->hello($smtp_domain); |
57 |
- } else { |
58 |
- die "Server does not support STARTTLS! ".$smtp->message; |
59 |
- } |
60 |
+ } |
61 |
+ |
62 |
+ $smtp ||= Net::SMTP->new($smtp_server, |
63 |
+ Hello => $smtp_domain, |
64 |
+ Port => $smtp_server_port, |
65 |
+ Debug => $debug_net_smtp, |
66 |
+ SSL => $smtp_ssl); |
67 |
+ |
68 |
+ if ($smtp_encryption eq 'tls' && $smtp) { |
69 |
+ $smtp->command('STARTTLS'); |
70 |
+ $smtp->response(); |
71 |
+ if ($smtp->code == 220) { |
72 |
+ $smtp->starttls(ssl_verify_params()) |
73 |
+ or die "STARTTLS failed! ".IO::Socket::SSL::errstr(); |
74 |
+ $smtp_encryption = ''; |
75 |
+ # Send EHLO again to receive fresh |
76 |
+ # supported commands |
77 |
+ $smtp->hello($smtp_domain); |
78 |
+ } else { |
79 |
+ die "Server does not support STARTTLS! ".$smtp->message; |
80 |
} |
81 |
} |
82 |
|