line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Haineko::Sample; |
2
|
1
|
|
|
1
|
|
1381
|
use feature ':5.10'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
106
|
|
3
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
32
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
5
|
1
|
|
|
1
|
|
1533
|
use utf8; |
|
1
|
|
|
|
|
12
|
|
|
1
|
|
|
|
|
7
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub mail { |
8
|
1
|
|
|
1
|
0
|
2
|
my $class = shift; |
9
|
1
|
|
|
|
|
2
|
my $httpd = shift; |
10
|
|
|
|
|
|
|
|
11
|
1
|
|
50
|
|
|
7
|
my $xforwarded = [ split( ',', $httpd->req->header('X-Forwarded-For') || q() ) ]; |
12
|
1
|
|
33
|
|
|
262
|
my $remoteaddr = pop @$xforwarded || $httpd->req->address // undef; |
|
|
|
50
|
|
|
|
|
13
|
1
|
|
|
|
|
46
|
my $samplemail = [ |
14
|
|
|
|
|
|
|
{ |
15
|
|
|
|
|
|
|
'mail' => 'envelope-sender-address@example.org', |
16
|
|
|
|
|
|
|
'rcpt' => [ 'envelope-recipient-address-1@example.jp' ], |
17
|
|
|
|
|
|
|
'ehlo' => sprintf( "[%s]", $remoteaddr ), |
18
|
|
|
|
|
|
|
'body' => 'Email message body', |
19
|
|
|
|
|
|
|
'header' => { |
20
|
|
|
|
|
|
|
'from' => 'Your Name ', |
21
|
|
|
|
|
|
|
'subject' => 'Email subject', |
22
|
|
|
|
|
|
|
'replyto' => 'another-email-address-if-you-want-to-receive@example.net', |
23
|
|
|
|
|
|
|
}, |
24
|
|
|
|
|
|
|
}, |
25
|
|
|
|
|
|
|
{ |
26
|
|
|
|
|
|
|
'helo' => 'your-host-name.example.net', |
27
|
|
|
|
|
|
|
'from' => 'envelope-sender-address@example.org', |
28
|
|
|
|
|
|
|
'to' => [ 'recipient1@example.com', 'recipient2@example.com' ], |
29
|
|
|
|
|
|
|
'body' => 'メールの本文(日本語)', |
30
|
|
|
|
|
|
|
'header' => { |
31
|
|
|
|
|
|
|
'from' => 'はいねこ ', |
32
|
|
|
|
|
|
|
'subject' => 'メールの件名', |
33
|
|
|
|
|
|
|
'charset' => 'UTF-8', |
34
|
|
|
|
|
|
|
}, |
35
|
|
|
|
|
|
|
}, |
36
|
|
|
|
|
|
|
]; |
37
|
|
|
|
|
|
|
|
38
|
1
|
|
|
|
|
6
|
return $httpd->res->json( 200, Haineko::JSON->dumpjson( $samplemail ) ); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
__END__ |