[rt-users] help with custom scrip condition

Vivek Khera vivek at khera.org
Tue Feb 19 12:56:31 EST 2008


I have the following scrip condition for my one of my queues, to  
prevent auto-replies to mail declared spam by spam assassin:

--cut here--
if ($self->TransactionObj->Type eq 'Create') {
   $RT::Logger->error("Got a create transacation...");
   my $co = $self->TransactionObj->ContentObj;
   return 0 unless $co;
   $RT::Logger->error("...checking if via email.");
   return 1 unless $co->GetHeader('Received');
   $RT::Logger->error("Looks like a juicy email");
   # check if email is flagged as spam.  assumes header set by mail  
server
   my $is_spam = $co->GetHeader('X-Spam-Flag') || 'nope';
   my $rv = $is_spam eq 'YES' ? 0 : 1;
   $RT::Logger->error("spam determination = $is_spam (autoreply =  
$rv)");
   return $rv;
} else {
   return 0; # do not run action
}
--cut here--

Is there some other (faster) preferred way to pull just the headers?

I have one message I'm trying to debug why we sent an autoreply to a  
message that clearly was declared spam.  It got to the step "checking  
if via email" in my scrip, then seems to have returned true when it  
didn't find a Received header.

I'm wondering if it is just timing out (no error in the log) since it  
took over 30 seconds to get the content object:

Feb 19 11:32:49 rt RT: Got a create transacation... ((eval 15255):2)
Feb 19 11:33:21 rt RT: ...checking if via email. ((eval 15255):5)


Actually, quite often I get my scrip terminate at this step, even  
though we almost always get tickets via email instead of at the UI.

Any ideas?




More information about the rt-users mailing list