1 # Copyright (C) 2014, Eric Wong <normalperson@yhbt.net> and all contributors
2 # License: AGPLv3 or later (https://www.gnu.org/licenses/agpl-3.0.txt)
13 my $f = Email::Filter->new(data => $s->as_string);
15 delete $ENV{ORIGINAL_RECIPIENT};
17 ok(PublicInbox->precheck($f),
18 "ORIGINAL_RECIPIENT unset is OK");
20 $ENV{ORIGINAL_RECIPIENT} = 'foo@example.com';
21 ok(!PublicInbox->precheck($f),
22 "wrong ORIGINAL_RECIPIENT rejected");
24 $ENV{ORIGINAL_RECIPIENT} = 'b@example.com';
25 ok(PublicInbox->precheck($f),
26 "ORIGINAL_RECIPIENT in To: is OK");
28 $ENV{ORIGINAL_RECIPIENT} = 'c@example.com';
29 ok(PublicInbox->precheck($f),
30 "ORIGINAL_RECIPIENT in Cc: is OK");
34 do_checks(Email::Simple->create(
36 From => 'a@example.com',
37 To => 'b@example.com',
38 Cc => 'c@example.com',
39 'Content-Type' => 'text/plain',
40 Subject => 'this is a subject',
41 'Message-ID' => '<MID>',
43 body => "hello world\n",
48 do_checks(Email::Simple->create(
50 From => 'a@example.com',
51 To => 'b+plus@example.com',
52 Cc => 'John Doe <c@example.com>',
53 'Content-Type' => 'text/plain',
54 Subject => 'this is a subject',
55 'Message-ID' => '<MID>',
57 body => "hello world\n",
62 $ENV{ORIGINAL_RECIPIENT} = 'b@example.com';
63 my $s = Email::Simple->create(
65 To => 'b@example.com',
66 Cc => 'c@example.com',
67 'Content-Type' => 'text/plain',
68 Subject => 'this is a subject',
69 'Message-ID' => '<MID>',
71 body => "hello world\n",
73 my $f = Email::Filter->new(data => $s->as_string);
74 ok(!PublicInbox->precheck($f), "missing From: is rejected");