| 1 | package Test::Smoke::Mailer::MIME_Lite; | ||||||||||||||||||||||||||||
| 2 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 3 | our $VERSION = '0.016'; | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use base 'Test::Smoke::Mailer::Base'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | =head1 Test::Smoke::Mailer::MIME_Lite | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | This handles sending the message using the B<MIME::Lite> module. | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | =head2 Test::Smoke::Mailer::MIME_Lite->new( %args ) | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | Keys for C<%args>: | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | * ddir | ||||||||||||||||||||||||||||
| 20 | * mserver | ||||||||||||||||||||||||||||
| 21 | * msport | ||||||||||||||||||||||||||||
| 22 | * msuser | ||||||||||||||||||||||||||||
| 23 | * mspass | ||||||||||||||||||||||||||||
| 24 | * to | ||||||||||||||||||||||||||||
| 25 | * from | ||||||||||||||||||||||||||||
| 26 | * cc | ||||||||||||||||||||||||||||
| 27 | * v | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | =cut | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | =head2 $mailer->mail( ) | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | C<mail()> sets up the message to be send by B<MIME::Lite>. | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | =cut | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 0 | ▶ | sub mail { | ||||||||||||||||||||||||||
|
Subroutine
mail: not called CC=16 SCAR=56.1
Pod
documented
| |||||||||||||||||||||||||||||
| 38 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 0 | eval { require MIME::Lite; }; | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 0 | ▶ | $self->{error} = $@ and return undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 0 | my $subject = $self->fetch_report(); | |||||||||||||||||||||||||||
| 45 | 0 | my $cc = $self->_get_cc( $subject ); | |||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | my %message = ( | ||||||||||||||||||||||||||||
| 48 | To => $self->{to}, | ||||||||||||||||||||||||||||
| 49 | Subject => $subject, | ||||||||||||||||||||||||||||
| 50 | Type => "TEXT", | ||||||||||||||||||||||||||||
| 51 | Data => $self->{body}, | ||||||||||||||||||||||||||||
| 52 | 0 | ); | |||||||||||||||||||||||||||
| 53 | 0 | ▶ | $message{Cc} = $cc if $cc; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | 0 | ▶ | $message{Bcc} = $self->{bcc} if $self->{bcc}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 55 | 0 | ▶ | $message{From} = $self->{from} if $self->{from}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 0 | ▶ | if ($self->{mserver}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | 0 | my %authinfo = (); | |||||||||||||||||||||||||||
| 59 | 0 | ▶ | $authinfo{AuthUser} = $self->{msuser} if $self->{msuser}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 60 | 0 | ▶ | $authinfo{AuthPass} = $self->{mspass} if defined $self->{mspass}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | MIME::Lite->send( | ||||||||||||||||||||||||||||
| 62 | smtp => $self->{mserver}, | ||||||||||||||||||||||||||||
| 63 | Port => ($self->{msport} || 25), | ||||||||||||||||||||||||||||
| 64 | FromSender => $self->{from}, | ||||||||||||||||||||||||||||
| 65 | 0 | ▶ | Debug => ($self->{v} > 1), | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'msport'} || 25
MC/DC0%0/1
$self->{'msport'} || 25
$self->{'msport'}
Truth table0%0/2
A
A= $self->{'msport'}
| |||||||||||||||||||||||||||||
| 66 | %authinfo, | ||||||||||||||||||||||||||||
| 67 | ); | ||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 0 | my $ml_msg = MIME::Lite->new( %message ); | |||||||||||||||||||||||||||
| 71 | $ml_msg->attr( 'content-type.charset' => 'UTF8' ) | ||||||||||||||||||||||||||||
| 72 | 0 | ▶ | if exists $ENV{LANG} && $ENV{LANG} =~ /utf-?8$/i; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $ENV{"LANG"} and $ENV{"LANG"} =~ /utf-?8$/i
MC/DC0%0/2
exists $ENV{"LANG"} and $ENV{"LANG"} =~ /utf-?8$/i
exists $ENV{"LANG"}
$ENV{"LANG"} =~ /utf-?8$/i
Truth table0%0/3
A and B
A= exists $ENV{"LANG"}B= $ENV{"LANG"} =~ /utf-?8$/i
| |||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 0 | ▶ | $self->{v} > 1 and print "[MIME::Lite]\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 75 | 0 | ▶ | $self->{v} and print "Sending report to $self->{to} "; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 0 | ▶ | $ml_msg->send or $self->{error} = "Problem sending mail"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 0 | ▶ | $self->{v} and print $self->{error} ? "not OK\n" : "OK\n"; | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 0 | return ! $self->{error}; | |||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 3 | 1; | |||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | (c) 2002-2013, All rights reserved. | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | * Abe Timmerman <abeltje@cpan.org> | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | This library is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||
| 93 | it under the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | See: | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | * <http://www.perl.com/perl/misc/Artistic.html>, | ||||||||||||||||||||||||||||
| 98 | * <http://www.gnu.org/copyleft/gpl.html> | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | This program is distributed in the hope that it will be useful, | ||||||||||||||||||||||||||||
| 101 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||||||||||||||||||||
| 102 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | =cut | ||||||||||||||||||||||||||||