User since
2003-08-04
7321
Artikel
ModeratorIn
hi...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
...
use MIME::Parser;
...
my $parser = new MIME::Parser();
$parser->ignore_errors(1);
$parser->output_dir($output);
$parser->output_prefix("msg");
$parser->extract_nested_messages(0);
$parser->output_to_core(0);
$parser->tmp_to_core(0);
$parser->use_inner_files(0);
$self->{entity} = $parser->parse_data($lines);
...
$self->extract_entity($cfg, $self->{entity});
...
sub extract_entity
{
my ($self, $cfg, $entity) = @_;
my @parts = $entity->parts;
if(scalar(@parts))
{
$self->extract_entity($cfg, $_) foreach (@parts);
}
else
{
my $type = $entity->head->mime_type || "";
my $location = $entity->head->mime_attr("content-location") || "";
my $charset = $entity->head->mime_attr('content-type.charset') || "";
my $body = $entity->bodyhandle;
my $cntid = $entity->head->mime_attr('content-id');
if($body)
{
my $path = $body->path;
$path =~ s!\\!/!g;
my $folder = Sources::Global::get_filepath($path);
if($cntid)
{
$cntid =~ s!^<|>$!!g;
my $temp = "$folder/$cntid";
Sources::Global::move_file($path, $temp);
$path = $temp;
}
$cfg->insert($path, "$type###$charset###$location");
# Sources::Global::encrypt($path);
if($type eq "message/rfc822")
{
}
elsif($type =~ m!ms-tnef!i)
{
my $tnef = Sources::Tnef->read_ent($entity, { output_dir => $folder });
my @atts = $tnef->attachments;
foreach my $attch (@atts)
{
my $fullpath = "$folder/".$attch->longname;
$cfg->insert($fullpath, "######");
if(open(FILE, "> $fullpath"))
{
binmode FILE;
print FILE $attch->data;
close FILE;
}
# Sources::Global::encrypt($fullpath);
}
$tnef->purge;
}
}
}
}
der code ist so nicht lauffähig; wollte dir nur zeigen, aus was du achten musst
$lines ist die complete Mail als string mit zeilenumbrüchen etcpp.
User since
2004-08-11
9
Artikel
BenutzerIn
Guten Morgen,
werde mal sehen was von beidem am besten möglich ist.
Vielen Dank für die Tips.
Gruß
Christian
User since
2004-08-11
9
Artikel
BenutzerIn
Hallo Zusammen,
bin noch relativ neu in Perl und habe ein kleines Problem:
ich möchte Mails auslesen (geht schon mit POP3Client) und deren Anhänge, sofern vorhanden herauskopieren und lokal abspeichern. Und genau letzteres bekomm ich nicht hin, d.h. ich habe nicht einmal einen Ansatz wie ich das machen könnte.
Habe da leider noch nichts brauchbares im Netz gefunden.
Wenn mir jemand einen kleinen Tip geben könnte wäre ich sehr dankbar.
Gruß
Christian
User since
2003-08-14
2022
Artikel
BenutzerIn
mimeexplode könnte deinen Anforderungen entsprechen.