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;