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 ok(PublicInbox->precheck($f, undef),
16 "RECIPIENT unset is OK");
18 my $recipient = 'foo@example.com';
19 ok(!PublicInbox->precheck($f, $recipient),
20 "wrong RECIPIENT rejected");
22 $recipient = 'b@example.com';
23 ok(PublicInbox->precheck($f, $recipient),
24 "RECIPIENT in To: is OK");
26 $recipient = 'c@example.com';
27 ok(PublicInbox->precheck($f, $recipient),
28 "RECIPIENT in Cc: is OK");
32 do_checks(Email::Simple->create(
34 From => 'a@example.com',
35 To => 'b@example.com',
36 Cc => 'c@example.com',
37 'Content-Type' => 'text/plain',
38 Subject => 'this is a subject',
39 'Message-ID' => '<MID>',
41 body => "hello world\n",
46 do_checks(Email::Simple->create(
48 From => 'a@example.com',
49 To => 'b+plus@example.com',
50 Cc => 'John Doe <c@example.com>',
51 'Content-Type' => 'text/plain',
52 Subject => 'this is a subject',
53 'Message-ID' => '<MID>',
55 body => "hello world\n",
60 my $recipient = 'b@example.com';
61 my $s = Email::Simple->create(
63 To => 'b@example.com',
64 Cc => 'c@example.com',
65 'Content-Type' => 'text/plain',
66 Subject => 'this is a subject',
67 'Message-ID' => '<MID>',
69 body => "hello world\n",
71 my $f = Email::Filter->new(data => $s->as_string);
72 ok(!PublicInbox->precheck($f, $recipient), "missing From: is rejected");