Subject: Re: [PATCH] send-email: remove documented requirement for Net::SMTP::SSL

From: Todd Zullinger <[email-masked]>
Date: Mon, 27 May 2019 20:05:44 -0400

Eric Wong wrote:
> Chris Mayo <[email-masked]> wrote:
>> git-send-email uses the TLS support in the Net::SMTP core module from
>> recent versions of Perl. Documenting the minimum version is complex
>> because of separate numbering for Perl (5.21.5~169), Net:SMTP (2.34)
>> and libnet (3.01). Version numbers from commit:
>> bfbfc9a953 ("send-email: Net::SMTP::starttls was introduced in v2.34",
>> 2017-05-31)
> 
> No disagreement for removing the doc requirement for Net::SMTP::SSL.
> 
> But core modules can be split out by OS packagers.  For
> Fedora/RH-based systems, the trend tends to be increasing
> granularity and having more optional packages.
> 
> So I think documenting Net::SMTP (and Net::Domain) as
> requirements would still be good, perhaps with a note stating
> they're typically installed with Perl.

I didn't know that git-send-email.perl could take advantage
of Net::SMTP::starttls until I read this.

[Adding Dennis and Jonathan as the authors of 0ead000c3a
("send-email: Net::SMTP::SSL is obsolete, use only when
necessary", 2017-03-24) bfbfc9a953 ("send-email:
Net::SMTP::starttls was introduced in v2.34", 2017-05-31),
respectively.]

The current Fedora and Red Hat package have a requirement on
Net::SMTP::SSL from long, long ago¹.  As I looked at whether
I could remove that (or more accurately, replace it with
IO::Socket::SSL which is needed for Net::SMTP to handle
starttls), I noticed that on RHEL7 the Net::SMTP version was
2.31, but starttls support has been backported².

I wonder if it's (separately from this change) worth
adjusting the conditional which sets $use_net_smtp_ssl to
use "Net::SMTP->can('starttls')" rather than a strict
version check?  (It might not be if using 'can' is too
fragile or would only benefit the Red Hat 7 packages which
likely won't officially be updated to a newer git with such
a change.)

Something like:

diff --git i/git-send-email.perl w/git-send-email.perl
index 24859a7bc3..84ac03994d 100755
--- i/git-send-email.perl
+++ w/git-send-email.perl
@@ -1465,7 +1465,7 @@ sub send_message {
 		}
 
 		require Net::SMTP;
-		my $use_net_smtp_ssl = version->parse($Net::SMTP::VERSION) < version->parse("2.34");
+		my $use_net_smtp_ssl = Net::SMTP->can('starttls') ? 0 : 1;
 		$smtp_domain ||= maildomain();
 
 		if ($smtp_encryption eq 'ssl') {

¹ https://bugzilla.redhat.com/443615
² https://bugzilla.redhat.com/1557574
  https://git.centos.org/rpms/perl/c/13dfe3?branch=c7

-- 
Todd