Schrift
[thread]4302[/thread]

Erfahrungen mit IMAP? (Seite 2)

Leser: 2


<< |< 1 2 >| >> 15 Einträge, 2 Seiten
esskar
 2005-06-22 14:55
#37671 #37671
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
MIME::Parser
esskar
 2005-06-22 15:30
#37672 #37672
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
Code: (dl )
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
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);
# hier könnte man wohl auch
# $self->{entity} = $parser->parse_open("/some/file.msg");
# sagen

my $cfg = Sources::Config->new(-filename => $infofile); # hier speicher ich mir ein paar sachen; brauchst du ggf nicht, oder anders

$self->extract_entity($cfg, $self->{entity});

$cfg->close();

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');
my $disposition = $entity->head->mime_attr('content-disposition');

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 => $type,
charset = $charset,
location => $location,
disposition => $disposition,
);

# Sources::Global::encrypt($path);

if($type eq "message/rfc822") {
# Spezialfall mail attachments
} elsif($type =~ m!ms-tnef!i) {
# Spezialfall tnef
}
}
}
}


HTH
J-jayz-Z
 2005-06-22 16:56
#37673 #37673
User since
2005-04-13
625 Artikel
BenutzerIn
[Homepage] [default_avatar]
Hmm, also steht dann in $body der mailbody drin, hab ich das richtig verstanden?
Aber wo wird die Variable $entity deklariert, damit ich $body auch einen Wert zuweisen kann? bzw. zu welchem Modul gehört $entity?
perl -Mstrict -Mwarnings -e 'package blub; sub new { bless {} } sub bar {my $self=shift; $self->{bla}="5065726c2d436f6d6d756e697479"; return $self->{bla};} my $foo=blub->new();print "Hallo ";print pack("H*",$foo->bar()); print "\n"'

http://perl-tutor.de
esskar
 2005-06-22 17:07
#37674 #37674
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
perldoc MIME::Parser
perldoc MIME::Entity

perldoc MIME::Lite
esskar
 2005-06-22 17:20
#37675 #37675
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
[quote=J-jayz-Z,22.06.2005, 15:08]Eine vorhandene mail lesen...[/quote]
und versteh ich "$body einen Wert zuweisen" nicht!
<< |< 1 2 >| >> 15 Einträge, 2 Seiten



View all threads created 2005-06-17 10:53.