| 1 | package Email::Sender::Transport::SMTP::Persistent 2.603; | ||||||||||||
| 2 | # ABSTRACT: an SMTP client that stays online | ||||||||||||
| 3 | |||||||||||||
| 4 | 1 | ▶ | use Moo; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 1 | extends 'Email::Sender::Transport::SMTP'; | |||||||||||
| 6 | |||||||||||||
| 7 | #pod =head1 DESCRIPTION | ||||||||||||
| 8 | #pod | ||||||||||||
| 9 | #pod The stock L<Email::Sender::Transport::SMTP> reconnects each time it sends a | ||||||||||||
| 10 | #pod message. This transport only reconnects when the existing connection fails. | ||||||||||||
| 11 | #pod | ||||||||||||
| 12 | #pod =cut | ||||||||||||
| 13 | |||||||||||||
| 14 | 1 | ▶ | use Net::SMTP; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 15 | |||||||||||||
| 16 | 1 | has _cached_client => ( | |||||||||||
| 17 | is => 'rw', | ||||||||||||
| 18 | ); | ||||||||||||
| 19 | |||||||||||||
| 20 | 0 | ▶ | sub _smtp_client { | ||||||||||
|
Subroutine
_smtp_client: not called CC=4 SCAR=30.0
| |||||||||||||
| 21 | 0 | my ($self) = @_; | |||||||||||
| 22 | |||||||||||||
| 23 | 0 | ▶ | if (my $client = $self->_cached_client) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 24 | 0 | ▶ | return $client if eval { $client->reset; $client->ok; }; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 25 | |||||||||||||
| 26 | 0 | ▶ | my $error = $@ | ||||||||||
|
Condition0%0/2
$@ || 'error resetting cached SMTP connection: ' . $client->message
MC/DC0%0/1
$@ || 'error resetting cached SMTP connection: ' . $client->message
$@
Truth table0%0/2
A
A= $@
| |||||||||||||
| 27 | || 'error resetting cached SMTP connection: ' . $client->message; | ||||||||||||
| 28 | |||||||||||||
| 29 | 0 | Carp::carp($error); | |||||||||||
| 30 | } | ||||||||||||
| 31 | |||||||||||||
| 32 | 0 | my $client = $self->SUPER::_smtp_client; | |||||||||||
| 33 | |||||||||||||
| 34 | 0 | $self->_cached_client($client); | |||||||||||
| 35 | |||||||||||||
| 36 | 0 | return $client; | |||||||||||
| 37 | } | ||||||||||||
| 38 | |||||||||||||
| 39 | 0 | ▶ | sub _message_complete { } | ||||||||||
|
Subroutine
_message_complete: not called CC=1 SCAR=0.0
| |||||||||||||
| 40 | |||||||||||||
| 41 | #pod =method disconnect | ||||||||||||
| 42 | #pod | ||||||||||||
| 43 | #pod $transport->disconnect; | ||||||||||||
| 44 | #pod | ||||||||||||
| 45 | #pod This method sends an SMTP QUIT command and destroys the SMTP client, if on | ||||||||||||
| 46 | #pod exists and is connected. | ||||||||||||
| 47 | #pod | ||||||||||||
| 48 | #pod =cut | ||||||||||||
| 49 | |||||||||||||
| 50 | 0 | ▶ | sub disconnect { | ||||||||||
|
Subroutine
disconnect: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||
| 51 | 0 | my ($self) = @_; | |||||||||||
| 52 | 0 | ▶ | return unless $self->_cached_client; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 53 | 0 | $self->_cached_client->quit; | |||||||||||
| 54 | 0 | $self->_cached_client(undef); | |||||||||||
| 55 | } | ||||||||||||
| 56 | |||||||||||||
| 57 | 1 | ▶ | no Moo; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 58 | 1 | 1; | |||||||||||
| 59 | |||||||||||||
| 60 | __END__ | ||||||||||||