Running Cron jobs

I’m running rt 3.0.11 on linux, with perl 5.8.3, mySQL and apache with mod_perl. There is nothing new in the rt.log file.

I am running rt-crontool with the following parameters.

30 * * * * /opt/rt3/bin/rt-crontool --search RT::Search::ActiveTicketsInQueue --search-arg VSATFaults --condition RT::Condition::UntouchedInHours --condition-arg 2 --action RT::Action::SystemNotify --action-arg Owner,AdminCc --template-id 20

I got the SytemNotify and LightWeightSendEmail.pm module from the mailing list and I have copied it to RT/Action directory. However, I don’t get any mails sent to the owner and AdminCC of the VSATFaults queue after creating a ticket in the queue and making sure it was untouched for 2hours. Please, what am I doing wrong? Is there a module I’m missing out.

PLEASE, can someone help out. Thanks.

The SystemNotify.pm module I’m using is:

RT::Action::SystemNotify>
package RT::Action::SystemNotify;
require RT::Action::LightWeightSendMail;

@ISA = qw(RT::Action::LightWeightSendMail);

{{{ sub SetRecipients

=head2 SetRecipients

Sets the recipients of this meesage to Owner, Requestor, AdminCc, Cc or All.
Explicitly B notify the creator of the transaction.

=cut

sub SetRecipients {
my $self = shift;

my $arg = $self->Argument;

$arg =~ s/\bAll\b/Owner,Requestor,AdminCc,Cc/;

my ( @To, @PseudoTo, @Cc, @Bcc );


if ( $arg =~ /\bRequestor\b/ ) {
    push ( @To, $self->TicketObj->Requestors->MemberEmailAddresses  );
}

if ( $arg =~ /\bCc\b/ ) {
    #If we have a To, make the Ccs, Ccs, otherwise, promote them to To
    if (@To) {
        push ( @Cc, $self->TicketObj->Cc->MemberEmailAddresses );
        push ( @Cc, $self->TicketObj->QueueObj->Cc->MemberEmailAddresses  );
    }
    else {
        push ( @Cc, $self->TicketObj->Cc->MemberEmailAddresses  );
        push ( @To, $self->TicketObj->QueueObj->Cc->MemberEmailAddresses  );
    }
}

if ( ( $arg =~ /\bOwner\b/ )
    && ( $self->TicketObj->OwnerObj->id != $RT::Nobody->id ) )
{
    # If we're not sending to Ccs or requestors, 
    # then the Owner can be the To.
    if (@To) {
        push ( @Bcc, $self->TicketObj->OwnerObj->EmailAddress );
    }
    else {
        push ( @To, $self->TicketObj->OwnerObj->EmailAddress );
    }

}

if ( $arg =~ /\bAdminCc\b/ ) {
    push ( @Bcc, $self->TicketObj->AdminCc->MemberEmailAddresses  );
    push ( @Bcc, $self->TicketObj->QueueObj->AdminCc->MemberEmailAddresses  );
}

if ($RT::UseFriendlyToLine) {
    unless (@To) {
        push ( @PseudoTo,
            "'$arg of $RT::rtname Ticket #"
              . $self->TicketObj->id . "':;" );
    }
}

#Strip the sender out of the To, Cc and AdminCc and set the 
# recipients fields used to build the message by the superclass.

$RT::Logger->debug("$self: To is ".join(",", at To));
$RT::Logger->debug("$self: Cc is ".join(",", at Cc));
$RT::Logger->debug("$self: Bcc is ".join(",", at Bcc));

@{ $self->{'To'} }  = @To;
@{ $self->{'Cc'} }  = @Cc;
@{ $self->{'Bcc'} } = @Bcc;
@{ $self->{'PseudoTo'} } = @PseudoTo;
return (1);

}

}}}

1;
</RT::Action::SystemNotify>

and the LightWeightSendEmail module is:

RT::Action::LightWeightSendEmail
package RT::Action::LightWeightSendMail;
require RT::Action::SendEmail;
@ISA = qw(RT::Action::SendEmail);

=head1 NAME

RT::Action::LightWeightSendmail - An action which users can use to
send mail out of RT (ex., in rt-crontool) without a RT::Transaction
object. It can be subclassed for more specialized mail sending
behavior.

You can pass it with an RT::Template object, but you can not use
$Transaction in it because it’s alwasy undef.

=cut

{{{ sub Describe

sub Describe {
my $self = shift;
return (ref $self . " will send an email to ticket’s owner.\n");
}

}}}

{{{ sub Prepare

sub Prepare {
my $self = shift;
# This actually populates the MIME::Entity fields in the Template Object

unless ($self->TemplateObj) {

$RT::Logger->warning(“No template object handed to $self\n”);
}

unless ($self->TicketObj) {

$RT::Logger->warning(“No ticket object handed to $self\n”);
}

$self->TemplateObj->Parse(Argument => $self->Argument,
     TicketObj => $self->TicketObj);

# Header

$self->SetSubject();

$self->SetSubjectToken();

$self->SetRecipients();  

$self->SetReturnAddress();

$self->SetRTSpecialHeaders();

return 1;

}

}}}

{{{ sub Commit

#Do what we need to do and send it out.
sub Commit {
my $self = shift;

# Go add all the Tos, Ccs and Bccs that we need to to the message to 
# make it happy, but only if we actually have values in those arrays.

$self->SetHeader('To', join(',', @{$self->{'To'}})) 

if (@{$self->{‘To’}});
$self->SetHeader(‘Cc’, join(’,’ , @{$self->{‘Cc’}}))
if (@{$self->{‘Cc’}});
$self->SetHeader(‘Bcc’, join(’,’, @{$self->{‘Bcc’}}))
if (@{$self->{‘Bcc’}});;

my $MIMEObj = $self->TemplateObj->MIMEObj;
$MIMEObj->make_singlepart;

#If we don't have any recipients to send to, don't send a message;
unless ($MIMEObj->head->get('To') ||
 $MIMEObj->head->get('Cc') || 
 $MIMEObj->head->get('Bcc') ) {

$RT::Logger->debug("$self: No recipients found. Not sending.\n");
return(1);
}

# PseudoTo (fake to headers) shouldn't get matched for message recipients.
# If we don't have any 'To' header, drop in the pseudo-to header.
$self->SetHeader('To', join(',', @{$self->{'PseudoTo'}}))

if ( (@{$self->{‘PseudoTo’}}) and (! $MIMEObj->head->get(‘To’)));

if ($RT::MailCommand eq 'sendmailpipe') {

open (MAIL, “|$RT::SendmailPath $RT::SendmailArguments”) || return(0);
print MAIL $MIMEObj->as_string;
close(MAIL);
}
else {
unless ($MIMEObj->send($RT::MailCommand, $RT::MailParams)) {
$RT::Logger->crit("$self: Could not send mail for “.$self->TransactionObj.”\n");
return(0);
}
}

return (1);

}

}}}

{{{ Deal with message headers (Set* subs, designed for easy overriding)

{{{ sub SetRTSpecialHeaders

This routine adds all the random headers that RT wants in a mail message

that don’t matter much to anybody else.

sub SetRTSpecialHeaders {
my $self = shift;

$self->SetReferences();

$self->SetPrecedence();

$self->SetHeader('X-RT-Loop-Prevention', $RT::rtname); 
$self->SetHeader('RT-Ticket', $RT::rtname. " #".$self->TicketObj->id());
$self->SetHeader
  ('Managed-by',"Request Tracker $RT::VERSION (http://www.fsck.com/projects/rt/)");

return();

}

}}}

{{{ sub SetReturnAddress

sub SetReturnAddress {
my $self = shift;
my %args = ( is_comment => 0,
@_ );

From and Reply-To

$args{is_comment} should be set if the comment address is to be used.

my $replyto;

if ($args{‘is_comment’}) {
$replyto = $self->TicketObj->QueueObj->CommentAddress ||
$RT::CommentAddress;
}
else {
$replyto = $self->TicketObj->QueueObj->CorrespondAddress ||
$RT::CorrespondAddress;
}

unless ($self->TemplateObj->MIMEObj->head->get(‘Reply-To’)) {
$self->SetHeader(‘Reply-To’, “$replyto”);
}
}

}}}

{{{ sub SetSubject

sub SetSubject {
my $self = shift;

my $subject = $self->{'Subject'} || "An email from RT";
$self->SetHeader('Subject', $subject);

return $subject;

}

}}}

1;
</RT::Action::LightWeightSendEmail>

ALL-NEW Yahoo! Messenger - all new features - even more fun!