4 use RT::Test tests => 38;
6 my $queue = RT::Test->load_or_create_queue(
8 CorrespondAddress => 'rt-recipient@example.com',
9 CommentAddress => 'rt-recipient@example.com',
11 ok $queue && $queue->id, 'loaded or created queue';
13 my $user = RT::Test->load_or_create_user(
15 EmailAddress => 'root@localhost',
17 ok $user && $user->id, 'loaded or created user';
19 diag "Reply to ticket with actor as one time cc";
21 my $ticket = RT::Ticket->new( RT::CurrentUser->new( $user ) );
22 my ($status, undef, $msg) = $ticket->Create(
25 Requestor => 'root@localhost',
27 ok $status, "created ticket";
29 my @mails = RT::Test->fetch_caught_mails;
30 ok @mails, "got some outgoing emails";
31 foreach my $mail ( @mails ) {
32 my $entity = parse_mail( $mail );
33 my $to = $entity->head->get('To');
35 is $to, 'root@localhost', 'got mail'
38 RT->Config->Set( NotifyActor => 1 );
39 ($status, $msg) = $ticket->Correspond(
40 Content => 'test mail',
42 ok $status, "replied to a ticket";
44 @mails = RT::Test->fetch_caught_mails;
45 ok @mails, "got some outgoing emails";
46 foreach my $mail ( @mails ) {
47 my $entity = parse_mail( $mail );
48 my $to = $entity->head->get('To');
50 is $to, 'root@localhost', 'got mail'
53 RT->Config->Set( NotifyActor => 0 );
54 ($status, $msg) = $ticket->Correspond(
55 Content => 'test mail',
57 ok $status, "replied to a ticket";
59 @mails = RT::Test->fetch_caught_mails;
60 ok !@mails, "no mail - don't notify actor";
62 ($status, $msg) = $ticket->Correspond(
63 Content => 'test mail',
64 CcMessageTo => 'root@localhost',
66 ok $status, "replied to a ticket";
68 @mails = RT::Test->fetch_caught_mails;
69 ok @mails, "got some outgoing emails";
70 foreach my $mail ( @mails ) {
71 my $entity = parse_mail( $mail );
72 my $to = $entity->head->get('Cc');
74 is $to, 'root@localhost', 'got mail'
78 diag "Reply to ticket with requestor squelched";
80 my $ticket = RT::Ticket->new( RT::CurrentUser->new( $user ) );
81 my ($status, undef, $msg) = $ticket->Create(
84 Requestor => 'test@localhost',
86 ok $status, "created ticket";
88 my @mails = RT::Test->fetch_caught_mails;
89 ok @mails, "got some outgoing emails";
90 foreach my $mail ( @mails ) {
91 my $entity = parse_mail( $mail );
92 my $to = $entity->head->get('To');
94 is $to, 'test@localhost', 'got mail'
97 ($status, $msg) = $ticket->Correspond(
98 Content => 'test mail',
100 ok $status, "replied to a ticket";
102 @mails = RT::Test->fetch_caught_mails;
103 ok @mails, "got some outgoing emails";
104 foreach my $mail ( @mails ) {
105 my $entity = parse_mail( $mail );
106 my $to = $entity->head->get('To');
107 $to =~ s/^\s+|\s+$//;
108 is $to, 'test@localhost', 'got mail'
111 $ticket->SquelchMailTo('test@localhost');
112 ($status, $msg) = $ticket->Correspond(
113 Content => 'test mail',
115 ok $status, "replied to a ticket";
117 @mails = RT::Test->fetch_caught_mails;
118 ok !@mails, "no mail - squelched";
120 ($status, $msg) = $ticket->Correspond(
121 Content => 'test mail',
122 CcMessageTo => 'test@localhost',
124 ok $status, "replied to a ticket";
126 @mails = RT::Test->fetch_caught_mails;
127 ok @mails, "got some outgoing emails";
128 foreach my $mail ( @mails ) {
129 my $entity = parse_mail( $mail );
130 my $to = $entity->head->get('Cc');
131 $to =~ s/^\s+|\s+$//;
132 is $to, 'test@localhost', 'got mail'
136 diag "Reply to ticket with requestor squelched";
138 my $ticket = RT::Ticket->new( RT::CurrentUser->new( $user ) );
139 my ($status, undef, $msg) = $ticket->Create(
142 Requestor => 'test@localhost',
144 ok $status, "created ticket";
146 my @mails = RT::Test->fetch_caught_mails;
147 ok @mails, "got some outgoing emails";
148 foreach my $mail ( @mails ) {
149 my $entity = parse_mail( $mail );
150 my $to = $entity->head->get('To');
151 $to =~ s/^\s+|\s+$//;
152 is $to, 'test@localhost', 'got mail'
155 ($status, $msg) = $ticket->Correspond(
156 Content => 'test mail',
158 ok $status, "replied to a ticket";
160 @mails = RT::Test->fetch_caught_mails;
161 ok @mails, "got some outgoing emails";
162 foreach my $mail ( @mails ) {
163 my $entity = parse_mail( $mail );
164 my $to = $entity->head->get('To');
165 $to =~ s/^\s+|\s+$//;
166 is $to, 'test@localhost', 'got mail'
169 ($status, $msg) = $ticket->Correspond(
170 Content => 'test mail',
171 SquelchMailTo => ['test@localhost'],
173 ok $status, "replied to a ticket";
175 @mails = RT::Test->fetch_caught_mails;
176 ok !@mails, "no mail - squelched";
178 ($status, $msg) = $ticket->Correspond(
179 Content => 'test mail',
181 ok $status, "replied to a ticket";
183 @mails = RT::Test->fetch_caught_mails;
184 ok @mails, "got some outgoing emails";
185 foreach my $mail ( @mails ) {
186 my $entity = parse_mail( $mail );
187 my $to = $entity->head->get('To');
188 $to =~ s/^\s+|\s+$//;
189 is $to, 'test@localhost', 'got mail'
192 ($status, $msg) = $ticket->Correspond(
193 Content => 'test mail',
194 CcMessageTo => 'test@localhost',
195 SquelchMailTo => ['test@localhost'],
197 ok $status, "replied to a ticket";
199 @mails = RT::Test->fetch_caught_mails;
200 ok @mails, "got some outgoing emails";
201 foreach my $mail ( @mails ) {
202 my $entity = parse_mail( $mail );
203 my $to = $entity->head->get('Cc');
204 $to =~ s/^\s+|\s+$//;
205 is $to, 'test@localhost', 'got mail'