| 1 | 1 | ▶ | use 5.014; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | package MailX::Qmail::Queue::Message; | ||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 1 | our $VERSION = '1.0'; | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use base 'Mail::Qmail::Queue::Message'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Mail::Address; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use Mail::Header; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | # Use inside-out attributes to avoid interference with base class: | ||||||||||||||||||||||||||||
| 14 | 1 | my ( %header, %body ); | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | sub header { | ||||||||||||||||||||||||||||
| 17 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
header: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 18 | 0 | ▶ | return $header{$self} if exists $header{$self}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 19 | 0 | ▶ | open my $fh, '<', $self->body_ref or die 'Cannot read message'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 20 | 0 | $header{$self} = Mail::Header->new($fh); | |||||||||||||||||||||||||||
| 21 | 0 | local $/; | |||||||||||||||||||||||||||
| 22 | 0 | $body{$self} = <$fh>; | |||||||||||||||||||||||||||
| 23 | 0 | $header{$self}; | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | sub header_from { | ||||||||||||||||||||||||||||
| 27 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
header_from: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 28 | 0 | ▶ | my $from = $self->header->get('From') or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 29 | 0 | ($from) = Mail::Address->parse($from); | |||||||||||||||||||||||||||
| 30 | 0 | $from; | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | sub helo { | ||||||||||||||||||||||||||||
| 34 | 0 | ▶ | my $header = shift->header; | ||||||||||||||||||||||||||
|
Subroutine
helo: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 35 | 0 | ▶ | my $received = $header->get('Received') or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | 0 | ▶ | $received =~ /^from .*? \(HELO (.*?)\) / | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$received =~ /^from .*? \(HELO (.*?)\) /u or $received =~ /^from (\S+) \(/u
MC/DC0%0/2
$received =~ /^from .*? \(HELO (.*?)\) /u or $received =~ /^from (\S+) \(/u
$received =~ /^from .*? \(HELO (.*?)\) /u
$received =~ /^from (\S+) \(/u
Truth table0%0/3
A or B
A= $received =~ /^from .*? \(HELO (.*?)\) /uB= $received =~ /^from (\S+) \(/u
| |||||||||||||||||||||||||||||
| 37 | or $received =~ /^from (\S+) \(/ | ||||||||||||||||||||||||||||
| 38 | or return; | ||||||||||||||||||||||||||||
| 39 | 0 | $1; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | sub add_header { | ||||||||||||||||||||||||||||
| 43 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
add_header: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 44 | 0 | ${ $self->body_ref } = join "\n", @_, $self->body; | |||||||||||||||||||||||||||
| 45 | 0 | delete $header{$self}; | |||||||||||||||||||||||||||
| 46 | 0 | $self; | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | sub replace_header { | ||||||||||||||||||||||||||||
| 50 | 0 | ▶ | my ( $self, $header ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
replace_header: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 51 | 0 | ▶ | $self->header unless exists $body{$self}; # force parsing | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | 0 | ▶ | $header = $header->as_string if ref $header && $header->can('as_string'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $header and $header->can("as_string")
MC/DC0%0/2
ref $header and $header->can("as_string")
ref $header
$header->can("as_string")
Truth table0%0/3
A and B
A= ref $headerB= $header->can("as_string")
| |||||||||||||||||||||||||||||
| 53 | 0 | ${ $self->body_ref } = join "\n", $header, $body{$self}; | |||||||||||||||||||||||||||
| 54 | 0 | delete $header{$self}; | |||||||||||||||||||||||||||
| 55 | 0 | $self; | |||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | sub DESTROY { | ||||||||||||||||||||||||||||
| 59 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 60 | 0 | delete $header{$self}; | |||||||||||||||||||||||||||
| 61 | 0 | delete $body{$self}; | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 1 | 1; | |||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | __END__ | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | =head1 NAME | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | MailX::Qmail::Queue::Message - extensions to Mail::Qmail::Queue::Message | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | This class extends L<Mail::Qmail::Queue::Message>. | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | =head1 METHODS | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | =over 4 | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | =item ->header | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | get the header of the incoming message as L<Mail::Header> object | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | =item ->header_from | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | get the C<From:> header field of the incoming message as L<Mail::Address> object | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | =item ->helo | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | get the C<HELO>/C<EHLO> string used by the client | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | =item ->add_header | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | Add header fields to the message. | ||||||||||||||||||||||||||||
| 95 | Expects C<Field: Value> as argument, without newlines at the end. | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | =item ->replace_header($header) | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | Replace the whole header of the message. | ||||||||||||||||||||||||||||
| 100 | C<$header> should either be a properly formatted e-mail header | ||||||||||||||||||||||||||||
| 101 | or an object with an C<as_string> method which produces such a string, | ||||||||||||||||||||||||||||
| 102 | e.g. a L<Mail::Header> object. | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | =back | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | =head1 BUGS | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | Please report any bugs or feature requests to | ||||||||||||||||||||||||||||
| 109 | C<bug-mail-qmail-filter at rt.cpan.org>, or through the web interface at | ||||||||||||||||||||||||||||
| 110 | L<https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Mail-Qmail-Filter>. | ||||||||||||||||||||||||||||
| 111 | I will be notified, and then you'll automatically be notified of progress on | ||||||||||||||||||||||||||||
| 112 | your bug as I make changes. | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | =head1 SUPPORT | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | You can find documentation for this module with the perldoc command. | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | perldoc Mail::Qmail::Filter | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | You can also look for information at: | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | =over 4 | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | =item * RT: CPAN's request tracker (report bugs here) | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | L<https://rt.cpan.org/NoAuth/Bugs.html?Dist=Mail-Qmail-Filter> | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | L<https://annocpan.org/dist/Mail-Qmail-Filter> | ||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | =item * CPAN Ratings | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | L<https://cpanratings.perl.org/dist/Mail-Qmail-Filter> | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | =item * Search CPAN | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | L<https://metacpan.org/release/Mail-Qmail-Filter> | ||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | =back | ||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | =head1 ACKNOWLEDGEMENTS | ||||||||||||||||||||||||||||
| 143 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | Copyright 2019 Martin Sluka. | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||
| 148 | under the terms of the the Artistic License (2.0). You may obtain a | ||||||||||||||||||||||||||||
| 149 | copy of the full license at: | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | L<http://www.perlfoundation.org/artistic_license_2_0> | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | Any use, modification, and distribution of the Standard or Modified | ||||||||||||||||||||||||||||
| 154 | Versions is governed by this Artistic License. By using, modifying or | ||||||||||||||||||||||||||||
| 155 | distributing the Package, you accept this license. Do not use, modify, | ||||||||||||||||||||||||||||
| 156 | or distribute the Package, if you do not accept this license. | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | If your Modified Version has been derived from a Modified Version made | ||||||||||||||||||||||||||||
| 159 | by someone other than you, you are nevertheless required to ensure that | ||||||||||||||||||||||||||||
| 160 | your Modified Version complies with the requirements of this license. | ||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | This license does not grant you the right to use any trademark, service | ||||||||||||||||||||||||||||
| 163 | mark, tradename, or logo of the Copyright Holder. | ||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | This license includes the non-exclusive, worldwide, free-of-charge | ||||||||||||||||||||||||||||
| 166 | patent license to make, have made, use, offer to sell, sell, import and | ||||||||||||||||||||||||||||
| 167 | otherwise transfer the Package with respect to any patent claims | ||||||||||||||||||||||||||||
| 168 | licensable by the Copyright Holder that are necessarily infringed by the | ||||||||||||||||||||||||||||
| 169 | Package. If you institute patent litigation (including a cross-claim or | ||||||||||||||||||||||||||||
| 170 | counterclaim) against any party alleging that the Package constitutes | ||||||||||||||||||||||||||||
| 171 | direct or contributory patent infringement, then this Artistic License | ||||||||||||||||||||||||||||
| 172 | to you shall terminate on the date that such litigation is filed. | ||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER | ||||||||||||||||||||||||||||
| 175 | AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. | ||||||||||||||||||||||||||||
| 176 | THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR | ||||||||||||||||||||||||||||
| 177 | PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY | ||||||||||||||||||||||||||||
| 178 | YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR | ||||||||||||||||||||||||||||
| 179 | CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR | ||||||||||||||||||||||||||||
| 180 | CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, | ||||||||||||||||||||||||||||
| 181 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | =cut | ||||||||||||||||||||||||||||