Skip Menu |

This queue is for tickets about the MailTools CPAN distribution.

Report information
The Basics
Id: 125871
Status: resolved
Priority: 0/
Queue: MailTools

People
Owner: Nobody in particular
Requestors: guilhem [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 2.18
Fixed in: (no value)



Subject: Mail::Mailer::smtp doesn't use STARTTLS
Since v1.28 Net::SMTP can issue STARTTLS commands. However Mail::Mailer::smtp doesn't support connection upgrade (STARTTLS SMTP command). I attach a patch adding a "StartTLS" option in that effect. Also, since Net::SMTP can also speak SMTP over SSL ("SSL => 1") and Net::SMTP::SSL is explicitly deprecated, I wonder if Mail::Mailer's "smtps" method should just alias to "'smtp', SSL => 1". (In that case the manpage would need to be modified accordingly.)
Subject: Mail::Mailer::smtp.patch
diff --git a/lib/Mail/Mailer.pm b/lib/Mail/Mailer.pm index e19d631..3fe19d7 100644 --- a/lib/Mail/Mailer.pm +++ b/lib/Mail/Mailer.pm @@ -50,9 +50,11 @@ The smtp mailer does not handle C<Cc> and C<Bcc> lines, neither their C<Resent-*> fellows. The C<Debug> options enables debugging output from C<Net::SMTP>. -You may also use the C<< Auth => [ $user, $password ] >> option for SASL -authentication. To make this work, you have to install the L<Authen::SASL> -distribution yourself: it is not automatically installed. +You may also use the C<< StartTLS => 1 >> options to upgrade the +connection with STARTTLS, and C<< Auth => [ $user, $password ] >> option +for SASL authentication. To make this work, you have to respectively +install the L<IO::Socket::SSL> and L<Authen::SASL> distribution +yourself: it is not automatically installed. =item C<smtps> diff --git a/lib/Mail/Mailer/smtp.pm b/lib/Mail/Mailer/smtp.pm index 3ecc1b4..938cbea 100644 --- a/lib/Mail/Mailer/smtp.pm +++ b/lib/Mail/Mailer/smtp.pm @@ -22,6 +22,11 @@ sub exec { my $smtp = Net::SMTP->new($host, %opt) or return undef; + if($opt{StartTLS}) + { $smtp->starttls() + or return undef; + } + if($opt{Auth}) { $smtp->auth(@{$opt{Auth}}) or return undef;
Subject: Re: [rt.cpan.org #125871] Mail::Mailer::smtp doesn't use STARTTLS
Date: Wed, 8 Aug 2018 16:21:05 +0200
To: Guilhem Moulin via RT <bug-MailTools [...] rt.cpan.org>
From: Mark Overmeer <solutions [...] overmeer.net>
* Guilhem Moulin via RT (bug-MailTools@rt.cpan.org) [180717 20:10]: Show quoted text
> Tue Jul 17 16:10:32 2018: Request 125871 was acted upon. > Transaction: Ticket created by GUILHEM > Queue: MailTools > Subject: Mail::Mailer::smtp doesn't use STARTTLS > Broken in: 2.18 > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=125871 >
I was on holidays, sorry for the delay. Show quoted text
> Since v1.28 Net::SMTP can issue STARTTLS commands. However > Mail::Mailer::smtp doesn't support connection upgrade (STARTTLS SMTP > command). I attach a patch adding a "StartTLS" option in that effect.
Mail::Mailer, as part of MailTools, is ancient and only kept alive because there is so much ancient code (and books with examples using it). No one should ever write new code this way: use Mail::Message::Transport and other things from Mail::Box. However... Show quoted text
> + if($opt{StartTLS}) > + { $smtp->starttls() > + or return undef; > + }
Your patch lacks the dependency upgrade required. And that's a complication. Net::SMTP 2.18 is from 2014, which is very young for MailTools users. I expect a considerable number of users running over 20 years infra- structures, still trying to upgrade for bug-fixes. So, I have modified your patch a little. See https://github.com/markov2/perl5-MailTools/commit/c4a0a4570cff54d5e05285f045a8114dc357d18a Does that match your expectations? -- Regards, MarkOv ------------------------------------------------------------------------ Mark Overmeer MSc MARKOV Solutions Mark@Overmeer.net solutions@overmeer.net http://Mark.Overmeer.net http://solutions.overmeer.net
On Wed Aug 08 10:45:34 2018, solutions@overmeer.net wrote: Show quoted text
> Does that match your expectations?
It does, thanks! I'll close this once 2.21 is released.
Option added to 2.21