- my ($status, undef, $msg) = $ticket->Create(
- Queue => $queue->id,
- Subject => 'test',
- Requestor => 'test@localhost',
- );
- ok $status, "created ticket";
-
- my @mails = RT::Test->fetch_caught_mails;
- ok @mails, "got some outgoing emails";
- foreach my $mail ( @mails ) {
- my $entity = parse_mail( $mail );
- my $to = $entity->head->get('To');
- $to =~ s/^\s+|\s+$//;
- is $to, 'test@localhost', 'got mail'
- }
-
- ($status, $msg) = $ticket->Correspond(
- Content => 'test mail',
- );
- ok $status, "replied to a ticket";
-
- @mails = RT::Test->fetch_caught_mails;
- ok @mails, "got some outgoing emails";
- foreach my $mail ( @mails ) {
- my $entity = parse_mail( $mail );
- my $to = $entity->head->get('To');
- $to =~ s/^\s+|\s+$//;
- is $to, 'test@localhost', 'got mail'
- }
-
- ($status, $msg) = $ticket->Correspond(
- Content => 'test mail',
- SquelchMailTo => ['test@localhost'],
- );
- ok $status, "replied to a ticket";
-
- @mails = RT::Test->fetch_caught_mails;
- ok !@mails, "no mail - squelched";
-
- ($status, $msg) = $ticket->Correspond(
- Content => 'test mail',
- );
- ok $status, "replied to a ticket";
-
- @mails = RT::Test->fetch_caught_mails;
- ok @mails, "got some outgoing emails";
- foreach my $mail ( @mails ) {
- my $entity = parse_mail( $mail );
- my $to = $entity->head->get('To');
- $to =~ s/^\s+|\s+$//;
- is $to, 'test@localhost', 'got mail'
- }
-
- ($status, $msg) = $ticket->Correspond(
- Content => 'test mail',
- CcMessageTo => 'test@localhost',
- SquelchMailTo => ['test@localhost'],
- );
- ok $status, "replied to a ticket";
-
- @mails = RT::Test->fetch_caught_mails;
- ok @mails, "got some outgoing emails";
- foreach my $mail ( @mails ) {
- my $entity = parse_mail( $mail );
- my $to = $entity->head->get('Cc');
- $to =~ s/^\s+|\s+$//;
- is $to, 'test@localhost', 'got mail'
- }
-}
+ mail_ok {
+ my ($status, undef, $msg) = $ticket->Create(
+ Queue => $queue->id,
+ Subject => 'test',
+ Requestor => 'test@localhost',
+ );
+ ok $status, "created ticket";
+ } { To => 'test@localhost' };
+
+ mail_ok {
+ my ($status, $msg) = $ticket->Correspond(
+ Content => 'test mail',
+ );
+ ok $status, "replied to a ticket";
+ } { To => 'test@localhost' };
+
+ mail_ok {
+ my ($status, $msg) = $ticket->Correspond(
+ Content => 'test mail',
+ SquelchMailTo => ['test@localhost'],
+ );
+ ok $status, "replied to a ticket";
+ };
+
+ mail_ok {
+ my ($status, $msg) = $ticket->Correspond(
+ Content => 'test mail',
+ );
+ ok $status, "replied to a ticket";
+ } { To => 'test@localhost' };
+
+ mail_ok {
+ my ($status, $msg) = $ticket->Correspond(
+ Content => 'test mail',
+ CcMessageTo => 'test@localhost',
+ SquelchMailTo => ['test@localhost'],
+ );
+ ok $status, "replied to a ticket";
+ } { Cc => 'test@localhost' };
+} [];
+
+diag "Requestor is an RT address";
+warnings_are {
+ my $ticket = RT::Ticket->new( RT::CurrentUser->new( $user ) );
+ mail_ok {
+ my ($status, undef, $msg) = $ticket->Create(
+ Queue => $queue->id,
+ Subject => 'test',
+ Requestor => 'rt-address@example.com',
+ );
+ ok $status, "created ticket";
+ } { To => 'rt-address@example.com' };
+
+ RT->Config->Set( RTAddressRegexp => qr/^rt-address\@example\.com$/i );
+ mail_ok {
+ my ($status, $msg) = $ticket->Correspond(
+ Content => 'test mail',
+ );
+ ok $status, "replied to a ticket";
+ };
+
+ mail_ok {
+ my ($status, $msg) = $ticket->Correspond(
+ Content => 'test mail',
+ CcMessageTo => 'rt-address@example.com',
+ );
+ ok $status, "replied to a ticket";
+ };
+} [];
+
+done_testing;