[rt-users] RT::Action::SendEmail / RT::Action::Notify example?

Alex Peters alex at peters.net
Thu Mar 25 20:51:50 EDT 2010


Hi,

I have written a Perl script run by cron that sends out emails
based on ticket states, e.g.:

1.  ticket is due in <= 48h and I haven't notified the owner
2.  ticket is new/open but has no activity in the past week
3.  ticket is stalled and its Starts date has lapsed

Currently it uses RT::Action::RecordComment to do this, because
I want some sort of record on the ticket that the email was
generated.

I'd prefer to use RT::Action::SendEmail or RT::Action::Notify
to do this, because then these notifications don't clutter up
the ticket view as much: RT users will just see an "outgoing
mail recorded" line and a link instead (if permitted).

The APIs for all three RT::Action modules seem quite similar,
but the SendEmail and Notify modules seem to require a
Transaction object while the RecordComment one doesn't.  I
don't know how I might go about fetching a Transaction object
or creating one.

Does anyone have a usage example of the SendEmail or Notify
modules to offer here?  Failing that, a way to get a
Transaction object from a ticket might be enough (but I admit
that I barely know what I'm doing at this early stage).

Here's what I'm doing to generate the comment:

     my $id = $ticket->Id;
     my $action_obj = RT::Action::RecordComment->new(
         Argument       => undef,
         CurrentUser    => $user,
         ScripActionObj => $void_scrip_action,
         ScripObj       => $void_scrip,
         TemplateObj    => $template,
         TicketObj      => $ticket,
         TransactionObj => undef,
     );
     warn "$id: preparation failed\n"
         if not $action_obj->Prepare;
     warn "$id: commit failed\n"
         if not $action_obj->Commit;

-- 
Cheers,
Alex



More information about the rt-users mailing list