line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::Exchange::Message::Email; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
1662
|
use Mail::Exchange::PidTagIDs; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
5929
|
|
4
|
2
|
|
|
2
|
|
17
|
use Mail::Exchange::Message; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
81
|
|
5
|
2
|
|
|
2
|
|
12
|
use Mail::Exchange::Recipient; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
77
|
|
6
|
2
|
|
|
2
|
|
1845
|
use Email::Address; |
|
2
|
|
|
|
|
80894
|
|
|
2
|
|
|
|
|
216
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Mail::Exchange::Message::Email - subclass of Mail::Exchange::Message |
11
|
|
|
|
|
|
|
that initializes Email-specific fields |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 SYNOPSIS |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
use Mail::Exchange::Message::Email; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
$mail=Mail::Exchange::Message::Email->new(); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 DESCRIPTION |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
Mail::Exchange::Message::Email is a utility class derived from |
22
|
|
|
|
|
|
|
Mail::Exchange::Message. When creating a new message object, it sets the |
23
|
|
|
|
|
|
|
Message Class to "IPM.Note" to mark this message as an email object. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=cut |
26
|
|
|
|
|
|
|
|
27
|
2
|
|
|
2
|
|
31
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
88
|
|
28
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
78
|
|
29
|
2
|
|
|
2
|
|
64
|
use 5.008; |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
76
|
|
30
|
|
|
|
|
|
|
|
31
|
2
|
|
|
2
|
|
12
|
use Exporter; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
126
|
|
32
|
|
|
|
|
|
|
|
33
|
2
|
|
|
2
|
|
12
|
use vars qw($VERSION @ISA); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
5582
|
|
34
|
|
|
|
|
|
|
@ISA=qw(Mail::Exchange::Message Exporter); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
$VERSION="0.03"; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 new() |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
$msg=Mail::Exchange::Message::Email->new(); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Create a new message object and initialize it to an email. |
43
|
|
|
|
|
|
|
=cut |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub new { |
46
|
0
|
|
|
0
|
|
|
my $class=shift; |
47
|
0
|
|
|
|
|
|
my $self=Mail::Exchange::Message->new(); |
48
|
0
|
|
|
|
|
|
$self->set(PidTagMessageClass, "IPM.Note"); |
49
|
0
|
|
|
|
|
|
bless $self; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head2 parse() |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
The parse() method is overwritten to abort, because the message type will be |
55
|
|
|
|
|
|
|
read from the input file, so a plain Mail::Exchange::Message object should |
56
|
|
|
|
|
|
|
be used in this case. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub parse { |
61
|
0
|
|
|
0
|
|
|
die("parse not supported, use a Mail::Exchange::Message object"); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 fromMIME() |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
fromMIME takes an Email::MIME object and returns a |
67
|
|
|
|
|
|
|
Mail::Exchange::Message::Email object. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=cut |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub fromMIME($) { |
72
|
|
|
|
|
|
|
my $class=shift; |
73
|
|
|
|
|
|
|
my $mime=shift; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
my $self=$class->new; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
die "wrong object type" if ref $mime ne "Email::MIME"; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
$self->set(PidTagStoreSupportMask, 0x40000); |
80
|
|
|
|
|
|
|
$self->set(PidTagMessageFlags, 1); |
81
|
|
|
|
|
|
|
$self->set(PidTagTransportMessageHeaders, |
82
|
|
|
|
|
|
|
$mime->header_obj->as_string()); |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
my (@from, @sender); |
85
|
|
|
|
|
|
|
if (@from=Email::Address->parse($mime->header('From'))) { |
86
|
|
|
|
|
|
|
$self->set(PidTagSentRepresentingAddressType, "SMTP"); |
87
|
|
|
|
|
|
|
$self->set(PidTagSentRepresentingEmailAddress, $from[0]->address); |
88
|
|
|
|
|
|
|
#$self->set(PidTagSentRepresentingSmtpAddress, $from[0]->address); |
89
|
|
|
|
|
|
|
$self->set(PidTagSentRepresentingName, $from[0]->name); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
if (!(@sender=Email::Address->parse($mime->header('Sender')))) { |
92
|
|
|
|
|
|
|
@sender=@from; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
if ($sender[0]) { |
95
|
|
|
|
|
|
|
$self->set(PidTagSenderAddressType, "SMTP"); |
96
|
|
|
|
|
|
|
$self->set(PidTagSenderEmailAddress, $sender[0]->address); |
97
|
|
|
|
|
|
|
$self->set(PidTagSenderSmtpAddress, $sender[0]->address); |
98
|
|
|
|
|
|
|
$self->set(PidTagSenderName, $sender[0]->name); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
my @headers=$mime->header_pairs; |
102
|
|
|
|
|
|
|
for (my $i=0; $i<=$#headers; $i+=2) { |
103
|
|
|
|
|
|
|
my $k=lc $headers[$i]; |
104
|
|
|
|
|
|
|
my $v=$headers[$i+1]; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
if ($k eq "cc") { |
107
|
|
|
|
|
|
|
$self->set(PidTagDisplayCc, $v); |
108
|
|
|
|
|
|
|
} elsif ($k eq "bcc") { |
109
|
|
|
|
|
|
|
$self->set(PidTagDisplayBcc, $v); |
110
|
|
|
|
|
|
|
} elsif ($k eq "to") { |
111
|
|
|
|
|
|
|
$self->set(PidTagDisplayTo, $v); |
112
|
|
|
|
|
|
|
} elsif ($k eq "date") { |
113
|
|
|
|
|
|
|
# $self->set(PidTagClientSubmitTime, dateparse($k)) |
114
|
|
|
|
|
|
|
} elsif ($k eq "importance") { |
115
|
|
|
|
|
|
|
$self->set(PidTagImportance, lc $v eq "low" ? 0 : |
116
|
|
|
|
|
|
|
lc $v eq "high" ? 2 : |
117
|
|
|
|
|
|
|
1); |
118
|
|
|
|
|
|
|
} elsif ($k eq "in-reply-to") { |
119
|
|
|
|
|
|
|
$self->set(PidTagInReplyToId, $v); |
120
|
|
|
|
|
|
|
} elsif ($k eq "message-id") { |
121
|
|
|
|
|
|
|
$self->set(PidTagInternetMessageId, $v); |
122
|
|
|
|
|
|
|
} elsif ($k eq "subject") { |
123
|
|
|
|
|
|
|
$self->setSubject($v); |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
foreach my $type qw(To Cc Bcc) { if ($mime->header($type)) { |
128
|
|
|
|
|
|
|
foreach my $address (Email::Address->parse($mime->header($type))) { |
129
|
|
|
|
|
|
|
my $recipient=Mail::Exchange::Recipient->new(); |
130
|
|
|
|
|
|
|
$recipient->setRecipientType($type); |
131
|
|
|
|
|
|
|
$recipient->setDisplayName($address->name); |
132
|
|
|
|
|
|
|
$recipient->setEmailAddress($address->address); |
133
|
|
|
|
|
|
|
$self->addRecipient($recipient); |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
}} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
# unfortunately, Email::MIME::walk_parts can' pass anything |
138
|
|
|
|
|
|
|
# through to the callback function so we can't use it. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
my @parts=($mime); |
141
|
|
|
|
|
|
|
while (my $part=pop @parts) { |
142
|
|
|
|
|
|
|
push(@parts, $part->subparts); |
143
|
|
|
|
|
|
|
next if ($part->{ct}{discrete} eq "multipart" |
144
|
|
|
|
|
|
|
|| $part->{ct}{discrete} eq "message"); |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
# If it has a filename, assume it's an attachment. |
147
|
|
|
|
|
|
|
# If it doesn't, and it's text/plain or text/html, set the |
148
|
|
|
|
|
|
|
# appropriate body part. Else invent a filename and attach it. |
149
|
|
|
|
|
|
|
my $filename; |
150
|
|
|
|
|
|
|
my $attach; |
151
|
|
|
|
|
|
|
if ($filename=$part->filename()) { |
152
|
|
|
|
|
|
|
$attach=Mail::Exchange::Attachment->new(); |
153
|
|
|
|
|
|
|
$attach->setFileName($filename); |
154
|
|
|
|
|
|
|
} elsif ($part->{ct}{discrete} eq "text" |
155
|
|
|
|
|
|
|
&& ($part->{ct}{composite} eq 'plain')) { |
156
|
|
|
|
|
|
|
$self->setBody($part->body); |
157
|
|
|
|
|
|
|
next; |
158
|
|
|
|
|
|
|
} elsif ($part->{ct}{discrete} eq "text" |
159
|
|
|
|
|
|
|
&& ($part->{ct}{composite} eq 'html')) { |
160
|
|
|
|
|
|
|
$self->setHTMLBody($part->body); |
161
|
|
|
|
|
|
|
next; |
162
|
|
|
|
|
|
|
} else { |
163
|
|
|
|
|
|
|
$attach=Mail::Exchange::Attachment->new(); |
164
|
|
|
|
|
|
|
$attach->setFileName($part->invent_filename( |
165
|
|
|
|
|
|
|
$part->header("Content-type"))); |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
$attach->setString($part->body); |
168
|
|
|
|
|
|
|
if (my $cid=$part->header("Content-ID")) { |
169
|
|
|
|
|
|
|
$attach->set(PidTagAttachContentId, $cid); |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
$self->addAttachment($attach); |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
$self; |
175
|
|
|
|
|
|
|
} |