line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Apache::WAP::MailPeek; |
2
|
1
|
|
|
1
|
|
689
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
39
|
|
3
|
1
|
|
|
1
|
|
1538
|
use Apache::Constants qw(:common); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
use Mail::Cclient; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
7
|
|
|
|
|
|
|
our $mail_server = 'brians.org'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Mail::Cclient::parameters( |
10
|
|
|
|
|
|
|
'NIL', |
11
|
|
|
|
|
|
|
RSHTIMEOUT => 0, |
12
|
|
|
|
|
|
|
OPENTIMEOUT => 1, |
13
|
|
|
|
|
|
|
READTIMEOUT => 1, |
14
|
|
|
|
|
|
|
CLOSETIMEOUT => 1, |
15
|
|
|
|
|
|
|
MAXLOGINTRIALS => 1, |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub handler { |
19
|
|
|
|
|
|
|
my $r = shift; |
20
|
|
|
|
|
|
|
my @msgnos = (); |
21
|
|
|
|
|
|
|
my %params = $r->method eq 'POST' ? $r->content : $r->args; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Mail::Cclient::set_callback |
24
|
|
|
|
|
|
|
login => sub { |
25
|
|
|
|
|
|
|
return $params{'username'}, $params{'password'} |
26
|
|
|
|
|
|
|
}, |
27
|
|
|
|
|
|
|
searched => sub { |
28
|
|
|
|
|
|
|
push (@msgnos, $_[1]); |
29
|
|
|
|
|
|
|
}, |
30
|
|
|
|
|
|
|
log => sub { print @_ }, dlog => sub { print @_}; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my $mail = Mail::Cclient->new("{$mail_server/imap}") or die $!; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
$r->content_type('text/vnd.wap.wml'); |
35
|
|
|
|
|
|
|
$r->send_http_header; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
$r->print(<
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
"http://www.wapforum.org/DTD/wml_1.1.xml"> |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
END |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
$mail->search("UNSEEN"); |
45
|
|
|
|
|
|
|
foreach my $msgno (@msgnos) { |
46
|
|
|
|
|
|
|
my ($envelope,$body) = $mail->fetchstructure($msgno); |
47
|
|
|
|
|
|
|
my $subject = $envelope->subject; |
48
|
|
|
|
|
|
|
my $from = ${$envelope->{from}}[0]->{personal} || |
49
|
|
|
|
|
|
|
${$envelope->{from}}[0]->{mailbox} . "@" . |
50
|
|
|
|
|
|
|
${$envelope->{from}}[0]->{host}; |
51
|
|
|
|
|
|
|
$from =~ s/\&/\&\;/g; $subject =~ s/\&/\&\;/g; |
52
|
|
|
|
|
|
|
$from =~ s/\$/\$\$/g; $subject =~ s/\$/\$\$/g; |
53
|
|
|
|
|
|
|
$r->print (" ", $from, ": ", $subject, " \n"); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
$mail->close; |
56
|
|
|
|
|
|
|
$r->print(""); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
1; |