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
MIME-Version: 1.0
X-Mailer: MIME-tools 5.504 (Entity 5.504)
X-RT-Interface: Web
Message-ID: <rt-4.0.18-21069-1531858232-626.0-0-0 [...] rt.cpan.org>
X-RT-Original-Encoding: utf-8
Content-Type: multipart/mixed; boundary="----------=_1531858232-21069-3"
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 0
Content-Disposition: inline
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: binary
Content-Length: 459
Download (untitled) / with headers
text/plain 459b
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
MIME-Version: 1.0
Content-Type: text/x-diff; name="Mail::Mailer::smtp.patch"
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline; filename="Mail::Mailer::smtp.patch"
Content-Transfer-Encoding: binary
Content-Length: 1285
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;
MIME-Version: 1.0
X-Cpan.org: This message routed through the cpan.org mail forwarding service. Please use PAUSE pause.perl.org to configure your delivery settings.
X-Spam-Flag: NO
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
content-type: text/plain; charset="utf-8"
X-RT-Original-Encoding: utf-8
X-Spam-Score: -5.84
Authentication-Results: hipster.bestpractical.com (amavisd-new); dkim=pass header.i= [...] overmeer.net
Authentication-Results: hipster.bestpractical.com (amavisd-new); domainkeys=pass header.from=solutions [...] overmeer.net
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id B43EC240251 for <cpan-bug+MailTools [...] hipster.bestpractical.com>; Wed, 8 Aug 2018 10:45:33 -0400 (EDT)
Received: from hipster.bestpractical.com ([127.0.0.1]) by localhost (hipster.bestpractical.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id I+UiqmpVVYo6 for <cpan-bug+MailTools [...] hipster.bestpractical.com>; Wed, 8 Aug 2018 10:45:31 -0400 (EDT)
Received: from xx1.develooper.com (xx1.develooper.com [207.171.7.115]) by hipster.bestpractical.com (Postfix) with ESMTPS id 6D0702400A3 for <bug-MailTools [...] rt.cpan.org>; Wed, 8 Aug 2018 10:45:31 -0400 (EDT)
Received: from localhost (xx1.develooper.com [127.0.0.1]) by localhost (Postfix) with ESMTP id 4817912342E for <bug-MailTools [...] rt.cpan.org>; Wed, 8 Aug 2018 07:45:30 -0700 (PDT)
Received: from xx1.develooper.com (xx1.develooper.com [127.0.0.1]) by localhost (Postfix) with SMTP id B7C701233F7 for <bug-MailTools [...] rt.cpan.org>; Wed, 8 Aug 2018 07:45:23 -0700 (PDT)
Received: from smtpq1.tb.mail.iss.as9143.net (smtpq1.tb.mail.iss.as9143.net [212.54.42.164]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by xx1.develooper.com (Postfix) with ESMTPS id 63BEA1233E2 for <bug-MailTools [...] rt.cpan.org>; Wed, 8 Aug 2018 07:45:00 -0700 (PDT)
Received: from [212.54.42.118] (helo=lsmtp4.tb.mail.iss.as9143.net) by smtpq1.tb.mail.iss.as9143.net with esmtp (Exim 4.86_2) (envelope-from <solutions [...] overmeer.net>) id 1fnPKl-0005Ws-7O for bug-MailTools [...] rt.cpan.org; Wed, 08 Aug 2018 16:21:07 +0200
Received: from dhcp-089-099-148-229.chello.nl ([89.99.148.229] helo=moon.overmeer.net) by lsmtp4.tb.mail.iss.as9143.net with esmtp (Exim 4.86_2) (envelope-from <solutions [...] overmeer.net>) id 1fnPKl-00038M-5a for bug-MailTools [...] rt.cpan.org; Wed, 08 Aug 2018 16:21:07 +0200
Received: from moon.overmeer.net (localhost [127.0.0.1]) by moon.overmeer.net (Postfix) with ESMTP id BCBF62F2D7 for <bug-MailTools [...] rt.cpan.org>; Wed, 8 Aug 2018 16:21:05 +0200 (CEST)
Received: from moon.overmeer.net (localhost [127.0.0.1]) by moon.overmeer.net (Postfix) with SMTP id A97D42F2D5 for <bug-MailTools [...] rt.cpan.org>; Wed, 8 Aug 2018 16:21:05 +0200 (CEST)
Delivered-To: cpan-bug+MailTools [...] hipster.bestpractical.com
Subject: Re: [rt.cpan.org #125871] Mail::Mailer::smtp doesn't use STARTTLS
Dkim-Signature: v=1; a=rsa-sha1; c=relaxed; d=overmeer.net; h=date:from :to:subject:message-id:references:mime-version:content-type :in-reply-to; s=home; bh=rqfMbgaciT6tYPH3gULHlz+SCfM=; b=aA88bCo RT4qFl3syTmsoYhAB0Ji4i9hl/qaIIhS6oJ/DAJ5MCxaj/IqWkaM6c5nCznwCNCm BtDbvHdYKCtaPj9Ss3LFOhJRiNyFlHVdXcgvZrEICDL54kj34RXZqSjmHYqBIVlX 3Jju6rms1Gk/t9bf6Ewb3bES0xHb1Yl1OOhc=
Date: Wed, 8 Aug 2018 16:21:05 +0200
X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' HTML_00_01 0.05, HTML_00_10 0.05, BODYTEXTP_SIZE_3000_LESS 0, BODY_ENDS_IN_URL_NOT_WWW 0, BODY_SIZE_1700_1799 0, BODY_SIZE_2000_LESS 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, DKIM_SIGNATURE 0, DOMAINKEY_SIG 0, IN_REP_TO 0, LEGITIMATE_SIGNS 0, MSG_THREAD 0, REFERENCES 0, SPF_NONE 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __BOUNCE_CHALLENGE_SUBJ 0, __BOUNCE_NDR_SUBJ_EXEMPT 0, __CD 0, __CP_URI_IN_BODY 0, __CT 0, __CT_TEXT_PLAIN 0, __DQ_NEG_HEUR 0, __DQ_NEG_IP 0, __FORWARDED_MSG 0, __FRAUD_MONEY_CURRENCY 0, __FRAUD_MONEY_CURRENCY_DOLLAR 0, __HAS_FROM 0, __HAS_MSGID 0, __HTTPS_URI 0, __IN_REP_TO 0, __MIME_TEXT_ONLY 0, __MIME_TEXT_P 0, __MIME_TEXT_P1 0, __MIME_VERSION 0, __MULTIPLE_URI_TEXT 0, __NO_HTML_TAG_RAW 0, __PHISH_SPEAR_SUBJ_SUBJECT 0, __REFERENCES 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __SUBJ_ALPHA_NEGATE 0, __SUBJ_REPLY 0, __TO_MALFORMED_2 0, __TO_NAME 0, __TO_NAME_DIFF_FROM_ACC 0, __TO_REAL_NAMES 0, __URI_IN_BODY 0, __URI_NOT_IMG 0, __URI_NO_WWW 0, __URI_NS , __URI_WITHOUT_PATH 0, __URI_WITH_PATH 0, __USER_AGENT 0, __blackholes.mail-abuse.org_TIMEOUT , __zen.spamhaus.org_ERROR '
X-Spam-Level:
X-Ziggo-Spam-Status: No
X-PMX-Version: 5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2018.8.8.143616
To: Guilhem Moulin via RT <bug-MailTools [...] rt.cpan.org>
In-Reply-To: <rt-4.0.18-21069-1531858233-1852.125871-4-0 [...] rt.cpan.org>
X-Spam-Status: No, score=-5.84 tagged_above=-99.9 required=10 tests=[AWL=0.160, BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FROM_OUR_RT=-4] autolearn=ham
Content-Disposition: inline
X-Ziggo-Spamscore: 0.0
X-RT-Interface: API
References: <RT-Ticket-125871 [...] rt.cpan.org> <rt-4.0.18-21069-1531858233-1852.125871-4-0 [...] rt.cpan.org>
X-Ziggo-Spamreport: CMAE Analysis: v=2.3 cv=JZEIUnCV c=1 sm=1 tr=0 a=BW2HpX0xbqX19mveOOJ22g==:17 a=eNcD7ojaAAAA:8 a=kj9zAlcOel0A:10 a=dapMudl6Dx4A:10 a=NEAV23lmAAAA:8 a=SNGdGZsoAAAA:8 a=gwGxybfFfuCi5UsBEFgA:9 a=CjuIK1q_8ugA:10 a=IYX7YI2ip6gA:10 a=rRYMMicksRHQPzyJ67jW:22 a=u8as8_5d3mMthsaxwyiH:22 none
Message-ID: <20180808142105.GF3694 [...] moon.overmeer.net>
X-Ziggo-Spambar: /
User-Agent: Mutt/1.8.3 (2017-05-23)
Return-Path: <solutions [...] overmeer.net>
Domainkey-Signature: a=rsa-sha1; c=nofws; d=overmeer.net; h=date:from:to :subject:message-id:references:mime-version:content-type :in-reply-to; q=dns; s=home; b=gJUEkNX2L7W98T3KGkS22jC7ZpSDxkT8L fv/8t7vv7qq5qWVUORgcWpBSG13gsGx6Lz5ZPbIuvRHTjnLUjB4Y0b5sd8ofEKDj 8Kem1IFhaN73OYTO0iRnSgaGkseTtgXui7uEUvN2OmeTrXfH9UYX6maiV3hLsVSR pfulipUWJ8=
X-RT-Mail-Extension: mailtools
X-Original-To: cpan-bug+MailTools [...] hipster.bestpractical.com
X-Sourceip: 89.99.148.229
X-Greylist: delayed 1431 seconds by postgrey-1.34 at xx1.develooper.com; Wed, 08 Aug 2018 07:45:02 PDT
From: Mark Overmeer <solutions [...] overmeer.net>
RT-Message-ID: <rt-4.0.18-25202-1533739534-1287.125871-0-0 [...] rt.cpan.org>
Content-Length: 1715
Download (untitled) / with headers
text/plain 1.6k
* 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
MIME-Version: 1.0
In-Reply-To: <rt-4.0.18-25202-1533739534-1287.125871-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
References: <RT-Ticket-125871 [...] rt.cpan.org> <rt-4.0.18-21069-1531858233-1852.125871-4-0 [...] rt.cpan.org> <20180808142105.GF3694 [...] moon.overmeer.net> <rt-4.0.18-25202-1533739534-1287.125871-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-22386-1533762621-1133.125871-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 153
Download (untitled) / with headers
text/plain 153b
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.
MIME-Version: 1.0
In-Reply-To: <rt-4.0.18-21069-1531858232-626.0-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
References: <rt-4.0.18-21069-1531858232-626.0-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-2743-1563627348-467.125871-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 20
Option added to 2.21


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.