line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Haineko::SMTPD::Relay::Screen; |
2
|
1
|
|
|
1
|
|
3055
|
use parent 'Haineko::SMTPD::Relay'; |
|
1
|
|
|
|
|
302
|
|
|
1
|
|
|
|
|
6
|
|
3
|
1
|
|
|
1
|
|
38
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
22
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
5
|
1
|
|
|
1
|
|
454
|
use Haineko::SMTPD::Response; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
186
|
|
6
|
1
|
|
|
1
|
|
979
|
use Email::MIME; |
|
1
|
|
|
|
|
75735
|
|
|
1
|
|
|
|
|
30
|
|
7
|
1
|
|
|
1
|
|
1139
|
use Time::Piece; |
|
1
|
|
|
|
|
11761
|
|
|
1
|
|
|
|
|
6
|
|
8
|
1
|
|
|
1
|
|
74
|
use Encode; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
521
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
3
|
|
|
3
|
1
|
5213
|
my $class = shift; |
12
|
3
|
|
|
|
|
11
|
my $argvs = { @_ }; |
13
|
|
|
|
|
|
|
|
14
|
3
|
|
66
|
|
|
47
|
$argvs->{'host'} = undef, |
15
|
|
|
|
|
|
|
$argvs->{'port'} = undef, |
16
|
|
|
|
|
|
|
$argvs->{'time'} ||= Time::Piece->new; |
17
|
3
|
|
|
|
|
406
|
$argvs->{'sleep'} = 0; |
18
|
3
|
|
|
|
|
33
|
$argvs->{'retry'} = 0; |
19
|
3
|
|
|
|
|
6
|
$argvs->{'timeout'} = 0; |
20
|
3
|
|
|
|
|
6
|
$argvs->{'startls'} = 0; |
21
|
3
|
|
|
|
|
12
|
return bless $argvs, __PACKAGE__; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub sendmail { |
25
|
1
|
|
|
1
|
1
|
11978
|
my $self = shift; |
26
|
|
|
|
|
|
|
|
27
|
1
|
|
|
|
|
4
|
my $headerlist = []; |
28
|
1
|
|
50
|
|
|
11
|
my $emencoding = uc( $self->{'attr'}->{'charset'} || 'UTF-8' ); |
29
|
1
|
|
|
|
|
9
|
my $methodargv = { |
30
|
1
|
|
|
|
|
3
|
'body' => Encode::encode( $emencoding, ${ $self->{'body'} } ), |
31
|
|
|
|
|
|
|
'attributes' => $self->{'attr'}, |
32
|
|
|
|
|
|
|
}; |
33
|
1
|
50
|
|
|
|
184
|
utf8::decode $methodargv->{'body'} unless utf8::is_utf8 $methodargv->{'body'} ; |
34
|
|
|
|
|
|
|
|
35
|
1
|
|
|
|
|
2
|
for my $e ( @{ $self->{'head'}->{'Received'} } ) { |
|
1
|
|
|
|
|
6
|
|
36
|
|
|
|
|
|
|
# Convert email headers |
37
|
0
|
|
|
|
|
0
|
push @$headerlist, 'Received' => $e; |
38
|
|
|
|
|
|
|
} |
39
|
1
|
|
|
|
|
3
|
push @$headerlist, 'To' => $self->{'rcpt'}; |
40
|
|
|
|
|
|
|
|
41
|
1
|
|
|
|
|
2
|
for my $e ( keys %{ $self->{'head'} } ) { |
|
1
|
|
|
|
|
6
|
|
42
|
|
|
|
|
|
|
# Make email headers except ``Received'' and ``MIME-Version'' |
43
|
4
|
100
|
|
|
|
20
|
next if $e eq 'Received'; |
44
|
3
|
50
|
|
|
|
6
|
next if $e eq 'MIME-Version'; |
45
|
|
|
|
|
|
|
|
46
|
3
|
50
|
|
|
|
9
|
if( ref $self->{'head'}->{ $e } eq 'ARRAY' ) { |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
0
|
for my $f ( @{ $self->{'head'}->{ $e } } ) { |
|
0
|
|
|
|
|
0
|
|
49
|
0
|
|
|
|
|
0
|
push @$headerlist, $e => $f; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
else { |
53
|
3
|
|
|
|
|
7
|
push @$headerlist, $e => $self->{'head'}->{ $e }; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
} |
56
|
1
|
|
|
|
|
4
|
$methodargv->{'header'} = $headerlist; |
57
|
|
|
|
|
|
|
|
58
|
1
|
|
|
|
|
13
|
my $mimeobject = Email::MIME->create( %$methodargv ); |
59
|
1
|
|
|
|
|
2581
|
my $mailstring = $mimeobject->as_string; |
60
|
1
|
|
|
|
|
94
|
my $smtpparams = { |
61
|
|
|
|
|
|
|
'dsn' => undef, |
62
|
|
|
|
|
|
|
'code' => 200, |
63
|
|
|
|
|
|
|
'host' => undef, |
64
|
|
|
|
|
|
|
'port' => undef, |
65
|
|
|
|
|
|
|
'rcpt' => $self->{'rcpt'}, |
66
|
|
|
|
|
|
|
'error' => 0, |
67
|
|
|
|
|
|
|
'mailer' => 'Screen', |
68
|
|
|
|
|
|
|
'message' => [ 'OK' ], |
69
|
|
|
|
|
|
|
'command' => 'DATA', |
70
|
|
|
|
|
|
|
}; |
71
|
1
|
|
|
|
|
13
|
$self->response( Haineko::SMTPD::Response->new( %$smtpparams ) ); |
72
|
|
|
|
|
|
|
|
73
|
1
|
50
|
|
|
|
12
|
utf8::encode $mailstring if utf8::is_utf8 $mailstring; |
74
|
1
|
|
|
|
|
132
|
printf( STDERR "%s", $mailstring ); |
75
|
|
|
|
|
|
|
|
76
|
1
|
|
|
|
|
33
|
return 1; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |
80
|
|
|
|
|
|
|
__END__ |