+
+# Use the ticket's scrips to figure out the new list of recipients.
+my @txns = grep {defined} map {$Ticket->DryRun( Action => $_ )} qw/comment respond/;
+my %recips=();
+for my $scrip (map {@{$_->Scrips->Prepared}} @txns) {
+ next unless $scrip->ActionObj->Action->isa('RT::Action::SendEmail');
+ for my $type (qw(To Cc Bcc)) {
+ $recips{$_->address} = 1 for $scrip->ActionObj->Action->$type();
+ }
+}
+for my $rule (map {@{$_->Rules}} @txns) {
+ next unless $rule->{hints} && $rule->{hints}{class} eq "SendEmail";
+ for my $type (qw(To Cc Bcc)) {
+ $recips{$_} = 1 for @{$rule->{hints}{recips}{$type}};
+ }
+}
+
+# Use tkt squelch list to get recipients who will NOT get mail:
+$recips{$_->Content} = 0 for $Ticket->SquelchMailTo;