6 use RT::Test tests => 38;
8 my $queue = RT::Test->load_or_create_queue(
10 CorrespondAddress => 'rt-recipient@example.com',
11 CommentAddress => 'rt-recipient@example.com',
13 ok $queue && $queue->id, 'loaded or created queue';
15 my $user = RT::Test->load_or_create_user(
17 EmailAddress => 'root@localhost',
19 ok $user && $user->id, 'loaded or created user';
21 diag "Reply to ticket with actor as one time cc";
23 my $ticket = RT::Ticket->new( RT::CurrentUser->new( $user ) );
24 my ($status, undef, $msg) = $ticket->Create(
27 Requestor => 'root@localhost',
29 ok $status, "created ticket";
31 my @mails = RT::Test->fetch_caught_mails;
32 ok @mails, "got some outgoing emails";
33 foreach my $mail ( @mails ) {
34 my $entity = parse_mail( $mail );
35 my $to = $entity->head->get('To');
37 is $to, 'root@localhost', 'got mail'
40 RT->Config->Set( NotifyActor => 1 );
41 ($status, $msg) = $ticket->Correspond(
42 Content => 'test mail',
44 ok $status, "replied to a ticket";
46 @mails = RT::Test->fetch_caught_mails;
47 ok @mails, "got some outgoing emails";
48 foreach my $mail ( @mails ) {
49 my $entity = parse_mail( $mail );
50 my $to = $entity->head->get('To');
52 is $to, 'root@localhost', 'got mail'
55 RT->Config->Set( NotifyActor => 0 );
56 ($status, $msg) = $ticket->Correspond(
57 Content => 'test mail',
59 ok $status, "replied to a ticket";
61 @mails = RT::Test->fetch_caught_mails;
62 ok !@mails, "no mail - don't notify actor";
64 ($status, $msg) = $ticket->Correspond(
65 Content => 'test mail',
66 CcMessageTo => 'root@localhost',
68 ok $status, "replied to a ticket";
70 @mails = RT::Test->fetch_caught_mails;
71 ok @mails, "got some outgoing emails";
72 foreach my $mail ( @mails ) {
73 my $entity = parse_mail( $mail );
74 my $to = $entity->head->get('Cc');
76 is $to, 'root@localhost', 'got mail'
80 diag "Reply to ticket with requestor squelched";
82 my $ticket = RT::Ticket->new( RT::CurrentUser->new( $user ) );
83 my ($status, undef, $msg) = $ticket->Create(
86 Requestor => 'test@localhost',
88 ok $status, "created ticket";
90 my @mails = RT::Test->fetch_caught_mails;
91 ok @mails, "got some outgoing emails";
92 foreach my $mail ( @mails ) {
93 my $entity = parse_mail( $mail );
94 my $to = $entity->head->get('To');
96 is $to, 'test@localhost', 'got mail'
99 ($status, $msg) = $ticket->Correspond(
100 Content => 'test mail',
102 ok $status, "replied to a ticket";
104 @mails = RT::Test->fetch_caught_mails;
105 ok @mails, "got some outgoing emails";
106 foreach my $mail ( @mails ) {
107 my $entity = parse_mail( $mail );
108 my $to = $entity->head->get('To');
109 $to =~ s/^\s+|\s+$//;
110 is $to, 'test@localhost', 'got mail'
113 $ticket->SquelchMailTo('test@localhost');
114 ($status, $msg) = $ticket->Correspond(
115 Content => 'test mail',
117 ok $status, "replied to a ticket";
119 @mails = RT::Test->fetch_caught_mails;
120 ok !@mails, "no mail - squelched";
122 ($status, $msg) = $ticket->Correspond(
123 Content => 'test mail',
124 CcMessageTo => 'test@localhost',
126 ok $status, "replied to a ticket";
128 @mails = RT::Test->fetch_caught_mails;
129 ok @mails, "got some outgoing emails";
130 foreach my $mail ( @mails ) {
131 my $entity = parse_mail( $mail );
132 my $to = $entity->head->get('Cc');
133 $to =~ s/^\s+|\s+$//;
134 is $to, 'test@localhost', 'got mail'
138 diag "Reply to ticket with requestor squelched";
140 my $ticket = RT::Ticket->new( RT::CurrentUser->new( $user ) );
141 my ($status, undef, $msg) = $ticket->Create(
144 Requestor => 'test@localhost',
146 ok $status, "created ticket";
148 my @mails = RT::Test->fetch_caught_mails;
149 ok @mails, "got some outgoing emails";
150 foreach my $mail ( @mails ) {
151 my $entity = parse_mail( $mail );
152 my $to = $entity->head->get('To');
153 $to =~ s/^\s+|\s+$//;
154 is $to, 'test@localhost', 'got mail'
157 ($status, $msg) = $ticket->Correspond(
158 Content => 'test mail',
160 ok $status, "replied to a ticket";
162 @mails = RT::Test->fetch_caught_mails;
163 ok @mails, "got some outgoing emails";
164 foreach my $mail ( @mails ) {
165 my $entity = parse_mail( $mail );
166 my $to = $entity->head->get('To');
167 $to =~ s/^\s+|\s+$//;
168 is $to, 'test@localhost', 'got mail'
171 ($status, $msg) = $ticket->Correspond(
172 Content => 'test mail',
173 SquelchMailTo => ['test@localhost'],
175 ok $status, "replied to a ticket";
177 @mails = RT::Test->fetch_caught_mails;
178 ok !@mails, "no mail - squelched";
180 ($status, $msg) = $ticket->Correspond(
181 Content => 'test mail',
183 ok $status, "replied to a ticket";
185 @mails = RT::Test->fetch_caught_mails;
186 ok @mails, "got some outgoing emails";
187 foreach my $mail ( @mails ) {
188 my $entity = parse_mail( $mail );
189 my $to = $entity->head->get('To');
190 $to =~ s/^\s+|\s+$//;
191 is $to, 'test@localhost', 'got mail'
194 ($status, $msg) = $ticket->Correspond(
195 Content => 'test mail',
196 CcMessageTo => 'test@localhost',
197 SquelchMailTo => ['test@localhost'],
199 ok $status, "replied to a ticket";
201 @mails = RT::Test->fetch_caught_mails;
202 ok @mails, "got some outgoing emails";
203 foreach my $mail ( @mails ) {
204 my $entity = parse_mail( $mail );
205 my $to = $entity->head->get('Cc');
206 $to =~ s/^\s+|\s+$//;
207 is $to, 'test@localhost', 'got mail'