How to write a scrip to change status to 'rejected' upon ticket creation


I need to create a scrip that will set the status to “rejected” upon creation of the ticket whenever the domain name is not part of a specific domain name. Let’s say that our own domain name is, we want all the tickets not coming from * and * to have a “rejected” status upon creation.

Maybe there’s something already out there that is similar to what I need.

Thx in advance.


There is a way to do this by writing a scrip, but it would be easier to move the email to a folder that is not monitored by RT in the mailbox, using some kind of mailbox rule.This way, you can use already implemented rules to do the same thing.

Hi Ivancni,

in RT the ticket will be created, anyway. After that you can set the status ‘rejected’. Depending on your Scrips there will be emails to Requestor and Watcher on creation and on rejecting.

So @ALone is right, maybe a mailbox with automatic answer (vacation) is easier.

If you want to do it in RT you need a script ‘OnCreate’ with Action ‘User Defined

Here’s an idea of code, not tested.

Custom preparation:

my $ticket = $self->TicketObj;
my $log_tag = $ticket->QueueObj->Name . "[YourTag#" . $ticket->id . "]: "; 
my $requestor_address = $self->TicketObj->RequestorAddresses;

# Test if requestor is in blocked domain
if( $requestor_address =~ m/.*\ ) 
	$RT::Logger->info($log_tag . "found requestor \, going on");
	$RT::Logger->info($log_tag . $requestor_address);
	return 1 
	$RT::Logger->info($log_tag . "Did not find \, leaving Scrip");
	$RT::Logger->info($log_tag . $requestor_address);
	return 0;

Custom action code:

# Do logging as needed, copy from above
return 1;

Hope it helps.

regards, Andre.