Reject incoming tickets

I would like RT to “reject” a message sent in with a subject tag that
indicates an ticket number that does not exist. Right now the behavior
is to ignore the tag and create a new ticket.

I created a custom action that properly sets the ticket’s status to
"rejected", but the autoreply template is still sent and the “Message
Rejected” template I created is not sent out. Below is the scrip:

Description: Reject messages to non-existent ticket
Condition: On Create
Action: User Defined
Template: Global Template: Invalid TicketID rejection message
Stage: TransactionCreate

Custom Action prep code:
1;

Custom action cleanup code:
my $tid =
$self->TransactionObj->Attachments->First->GetHeader(‘X-MyHeader’);

$RT::Logger->debug(“Reject Non-Tickets – got X-MyHeader: $tid”);

if (defined $tid) {
my $t1 = RT::Ticket->new($RT::SystemUser);

if (not $t1->Load($tid)) {
    $RT::Logger->debug("Reject Non-Tickets -- rejecting 

message…");
$self->TicketObj->Reject;
} else {
return 1;
}
} else {
$RT::Logger->debug(“Reject Non-Tickets – a new ticket w/o
X-MyHeader field…”);
return 1;
}

Thanks.

Trask
Technical Support Engineer
Lyris Technologies, Inc.