line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Sietima::Message; |
2
|
16
|
|
|
16
|
|
115
|
use Moo; |
|
16
|
|
|
|
|
34
|
|
|
16
|
|
|
|
|
139
|
|
3
|
16
|
|
|
16
|
|
5852
|
use Sietima::Policy; |
|
16
|
|
|
|
|
67
|
|
|
16
|
|
|
|
|
180
|
|
4
|
16
|
|
|
16
|
|
108
|
use Types::Standard qw(ArrayRef Object); |
|
16
|
|
|
|
|
42
|
|
|
16
|
|
|
|
|
110
|
|
5
|
16
|
|
|
|
|
90
|
use Sietima::Types qw(Address AddressFromStr |
6
|
|
|
|
|
|
|
Subscriber SubscriberFromAddress SubscriberFromStr |
7
|
16
|
|
|
16
|
|
14088
|
EmailMIME); |
|
16
|
|
|
|
|
34
|
|
8
|
16
|
|
|
16
|
|
15109
|
use Email::Address; |
|
16
|
|
|
|
|
34
|
|
|
16
|
|
|
|
|
375
|
|
9
|
16
|
|
|
16
|
|
6303
|
use Sietima::Subscriber; |
|
16
|
|
|
|
|
59
|
|
|
16
|
|
|
|
|
629
|
|
10
|
16
|
|
|
16
|
|
128
|
use Email::MIME; |
|
16
|
|
|
|
|
35
|
|
|
16
|
|
|
|
|
391
|
|
11
|
16
|
|
|
16
|
|
84
|
use namespace::clean; |
|
16
|
|
|
|
|
33
|
|
|
16
|
|
|
|
|
127
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '1.0.4'; # VERSION |
14
|
|
|
|
|
|
|
# ABSTRACT: an email message with an envelope |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has mail => ( |
18
|
|
|
|
|
|
|
is => 'ro', |
19
|
|
|
|
|
|
|
isa => EmailMIME, |
20
|
|
|
|
|
|
|
required => 1, |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has from => ( |
25
|
|
|
|
|
|
|
is => 'ro', |
26
|
|
|
|
|
|
|
isa => Address, |
27
|
|
|
|
|
|
|
coerce => AddressFromStr, |
28
|
|
|
|
|
|
|
required => 1, |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my $subscriber_array = ArrayRef[ |
33
|
|
|
|
|
|
|
Subscriber->plus_coercions( |
34
|
|
|
|
|
|
|
SubscriberFromStr, |
35
|
|
|
|
|
|
|
SubscriberFromAddress, |
36
|
|
|
|
|
|
|
) |
37
|
|
|
|
|
|
|
]; |
38
|
|
|
|
|
|
|
has to => ( |
39
|
|
|
|
|
|
|
isa => $subscriber_array, |
40
|
|
|
|
|
|
|
is => 'ro', |
41
|
|
|
|
|
|
|
coerce => $subscriber_array->coercion, |
42
|
|
|
|
|
|
|
required => 1, |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
25
|
|
|
25
|
1
|
147
|
sub envelope ($self) { |
|
25
|
|
|
|
|
45
|
|
|
25
|
|
|
|
|
46
|
|
47
|
|
|
|
|
|
|
return { |
48
|
|
|
|
|
|
|
from => $self->from, |
49
|
25
|
|
|
|
|
158
|
to => [ map { $_->address } $self->to->@* ], |
|
41
|
|
|
|
|
1524
|
|
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
__END__ |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=pod |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=encoding UTF-8 |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 NAME |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Sietima::Message - an email message with an envelope |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 VERSION |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
version 1.0.4 |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 SYNOPSIS |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
use Sietima::Message; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
my $msg = Sietima::Message->new({ |
74
|
|
|
|
|
|
|
mail => $email_mime_object, |
75
|
|
|
|
|
|
|
from => 'sender@example.com', |
76
|
|
|
|
|
|
|
to => [ 'recipient@example.com', 'also@example.com' ], |
77
|
|
|
|
|
|
|
}); |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 DESCRIPTION |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
This class pairs a L<< C<Email::MIME> >> object with its |
82
|
|
|
|
|
|
|
envelope. Objects of this class are usually generated by L<< |
83
|
|
|
|
|
|
|
C<Sietima::munge_mail>|Sietima/munge_mail >>, and consumed by L<< |
84
|
|
|
|
|
|
|
C<Sietima::send_message>|Sietima/send_message >>. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
All attributes are read-only and required. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 C<mail> |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
An L<< C<Email::MIME> >> object, representing the message. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head2 C<from> |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
An L<< C<Email::Address> >> object, coercible from a string, |
97
|
|
|
|
|
|
|
representing the sender. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head2 C<to> |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
An arrayref of L<< C<Sietima::Subscriber> >> objects, each coercible |
102
|
|
|
|
|
|
|
from a string or an L<< C<Email::Address> >> object, representing the |
103
|
|
|
|
|
|
|
recipients. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 METHODS |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head2 C<envelope> |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
my %envelope = $message->envelope->%*; |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Returns a hashref with envelope data, suitable for use with L<< |
112
|
|
|
|
|
|
|
C<Email::Sender::Transport::send>|Email::Sender::Transport/send >>. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 AUTHOR |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Gianni Ceccarelli <dakkar@thenautilus.net> |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Gianni Ceccarelli <dakkar@thenautilus.net>. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
123
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=cut |