| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# (c)2000 Matthew MacKenzie |
|
2
|
|
|
|
|
|
|
# License: Artistic or LGPL, your choice. |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Mail::XML; |
|
5
|
1
|
|
|
1
|
|
532
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
27
|
|
|
6
|
1
|
|
|
1
|
|
1250
|
use Mail::Internet; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use XML::Writer; |
|
8
|
|
|
|
|
|
|
use IO::Scalar; |
|
9
|
|
|
|
|
|
|
use Carp; |
|
10
|
|
|
|
|
|
|
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
require Exporter; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
@ISA = qw(Exporter Mail::Internet); |
|
15
|
|
|
|
|
|
|
$VERSION = '0.03'; |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub toXML { |
|
18
|
|
|
|
|
|
|
my ($self) = shift; |
|
19
|
|
|
|
|
|
|
my $head = $self->head() || croak; |
|
20
|
|
|
|
|
|
|
my $body = $self->body() || croak; |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $data = ""; |
|
23
|
|
|
|
|
|
|
my $hdl = new IO::Scalar(\$data); |
|
24
|
|
|
|
|
|
|
my $w = new XML::Writer(OUTPUT => $hdl); |
|
25
|
|
|
|
|
|
|
$w->xmlDecl("ISO-8859-1"); |
|
26
|
|
|
|
|
|
|
$w->comment("Mail::XML version " . $VERSION); |
|
27
|
|
|
|
|
|
|
$w->startTag("Message"); |
|
28
|
|
|
|
|
|
|
$w->startTag("Head"); |
|
29
|
|
|
|
|
|
|
foreach my $tag ($head->tags()) { |
|
30
|
|
|
|
|
|
|
chomp(my $c = $head->get($tag)); |
|
31
|
|
|
|
|
|
|
if ($tag =~ m!From\s!) { |
|
32
|
|
|
|
|
|
|
$tag = "MTA_From"; |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
$w->startTag($tag); |
|
35
|
|
|
|
|
|
|
$w->characters($c); |
|
36
|
|
|
|
|
|
|
$w->endTag($tag); |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
$w->endTag("Head"); |
|
39
|
|
|
|
|
|
|
$w->startTag("Body"); |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
foreach (@$body) { |
|
42
|
|
|
|
|
|
|
$w->characters($_); |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
$w->endTag("Body"); |
|
45
|
|
|
|
|
|
|
$w->endTag("Message"); |
|
46
|
|
|
|
|
|
|
$w->end(); |
|
47
|
|
|
|
|
|
|
$hdl->close(); |
|
48
|
|
|
|
|
|
|
return $data; |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
|
52
|
|
|
|
|
|
|
__END__ |