<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;"># Copyrights 1995-2019 by [Mark Overmeer &lt;markov@cpan.org&gt;].
#  For other contributors see ChangeLog.
# See the manual pages for details on the licensing terms.
# Pod stripped from pm file by OODoc 2.02.
# This code is part of the bundle MailTools.  Meta-POD processed with
# OODoc into POD and HTML manual-pages.  See README.md for Copyright.
# Licensed under the same terms as Perl itself.

# Based on smtp.pm, adapted by Maciej Ĺ»enczykowski

package Mail::Mailer::smtps;
use vars '$VERSION';
$VERSION = '2.21';

use base 'Mail::Mailer::rfc822';

use strict;

use Net::SMTP::SSL;
use Mail::Util qw(mailaddress);
use Carp;

sub can_cc { 0 }

sub exec {
    my ($self, $exe, $args, $to) = @_;
    my %opt   = @$args;
    my $host  = $opt{Server} || undef;
    $opt{Debug} ||= 0;
    $opt{Port}  ||= 465;

    my $smtp = Net::SMTP::SSL-&gt;new($host, %opt)
	or return undef;

    if($opt{Auth})
    {   $smtp-&gt;auth(@{$opt{Auth}})
           or return undef;
    }

    ${*$self}{sock} = $smtp;

    $smtp-&gt;mail($opt{From} || mailaddress);
    $smtp-&gt;to($_) for @$to;
    $smtp-&gt;data;

    untie *$self if tied *$self;
    tie *$self, 'Mail::Mailer::smtps::pipe', $self;
    $self;
}

sub set_headers($)
{   my ($self, $hdrs) = @_;
    $self-&gt;SUPER::set_headers
     ( { From =&gt; "&lt;" . mailaddress() . "&gt;"
       , %$hdrs
       , 'X-Mailer' =&gt; "Mail::Mailer[v$Mail::Mailer::VERSION] "
           . " Net::SMTP[v$Net::SMTP::VERSION]"
           . " Net::SMTP::SSL[v$Net::SMTP::SSL::VERSION]"
       }
     );
}

sub epilogue()
{   my $self = shift;
    my $sock = ${*$self}{sock};

    my $ok = $sock-&gt;dataend;
    $sock-&gt;quit;

    delete ${*$self}{sock};
    untie *$self;
    $ok;
}

sub close(@)
{   my ($self, @to) = @_;
    my $sock = ${*$self}{sock};

    $sock &amp;&amp; fileno $sock
        or return 1;

    my $ok = $self-&gt;epilogue;

    # Epilogue should destroy the SMTP filehandle,
    # but just to be on the safe side.
    $sock &amp;&amp; fileno $sock
        or return $ok;

    close $sock
        or croak 'Cannot destroy socket filehandle';

    $ok;
}

package Mail::Mailer::smtps::pipe;
use vars '$VERSION';
$VERSION = '2.21';


sub TIEHANDLE
{   my ($class, $self) = @_;
    my $sock = ${*$self}{sock};
    bless \$sock, $class;
}

sub PRINT
{   my $self = shift;
    my $sock = $$self;
    $sock-&gt;datasend( @_ );
}

1;
</pre></body></html>