ScriptedAction not sending mail

Hi all,

Today we tried using ScriptedAction for the first time since installing RTIR 2.4.3. Investigations were created, but our logs were showing an error:

Jul 15 12:51:11 ostrv RT: rt-3.8.7-28730-1279191071-65.37311-92-0@arnes.si #37311/268782 - Scrip 92 CreateInvestigation (/opt/rt3/bin/…/lib/RT/Action/SendEmail.pm:300)
Jul 15 12:51:11 ostrv RT: rt-3.8.7-28730-1279191071-65.37311-92-0@arnes.si No recipients found. Not sending. (/opt/rt3/bin/…/lib/RT/Interface/Email.pm:342)

After going through the code I found out that requestor is not set to the correct e-mail address before ScriptedAction.html calls CreateTicket( %ARGS, … ). So you should stuff that address in the %ARGS hash (the third change in the diff below). I took the opportunity to add a field where you can specify the parent incident for all investigations being created (first two changes in the diff).

diff -c /opt/src/RT-IR-2.4.3/html/RTIR/Tools/ScriptedAction.html local/plugins/RT-IR/html/RTIR/Tools/ScriptedAction.html

*** /opt/src/RT-IR-2.4.3/html/RTIR/Tools/ScriptedAction.html 2009-08-18 17:26:46.000000000 +0200
— local/plugins/RT-IR/html/RTIR/Tools/ScriptedAction.html 2010-07-15 13:38:14.000000000 +0200
*** 31,37 ****
<& /Elements/ListActions, actions => @finalresults &>

- --- 31,36 ---- *** 132,137 **** --- 131,144 ---- + + + <&|/l&>Link to incident: + + + + + *** 313,318 **** --- 320,326 ----
      $ARGS{'Subject'} = $original_subject;
      $ARGS{'Content'} = $original_content;
  • $ARGS{‘Requestors’} = $addr;

      for (qw/Subject Content/) {
          $ARGS{$_} =~ s/_ADDR_/$addr/g;
    

— end of diff —

I noticed this further down:

    my @watchresults = ProcessTicketWatchers(
        TicketObj => $Ticket,
        ARGSRef => { %ARGS, AddRequestor => $addr },
    );

This meant that we could see requestors in investigation tickets OK, but no mail was being sent out! Confusing.

Well - of course, since at the time the ticket was created, the requestor was not specified yet (thus the corresponding Scrip error that no recipients are listed). Later in the loop when the requestor was added this does not trigger any scrips that deal with correspondence! IMO.

Regards,
Gorazd

Gorazd Bozic gorazd.bozic@arnes.si
ARNES SI-CERT, Tehnološki park 18, p.p. 7, SI-1001 Ljubljana, Slovenia
tel: +386 1 479 88 22, fax: +386 1 479 88 23

Gorazd,

Would you mind resending that patch as a unified diff?

Thanks!
JesseOn Thu, Jul 15, 2010 at 02:12:23PM +0200, Gorazd Božič wrote:

Hi all,

Today we tried using ScriptedAction for the first time since installing RTIR 2.4.3. Investigations were created, but our logs were showing an error:

Jul 15 12:51:11 ostrv RT: rt-3.8.7-28730-1279191071-65.37311-92-0@arnes.si #37311/268782 - Scrip 92 CreateInvestigation (/opt/rt3/bin/…/lib/RT/Action/SendEmail.pm:300)
Jul 15 12:51:11 ostrv RT: rt-3.8.7-28730-1279191071-65.37311-92-0@arnes.si No recipients found. Not sending. (/opt/rt3/bin/…/lib/RT/Interface/Email.pm:342)

After going through the code I found out that requestor is not set to the correct e-mail address before ScriptedAction.html calls CreateTicket( %ARGS, … ). So you should stuff that address in the %ARGS hash (the third change in the diff below). I took the opportunity to add a field where you can specify the parent incident for all investigations being created (first two changes in the diff).

diff -c /opt/src/RT-IR-2.4.3/html/RTIR/Tools/ScriptedAction.html local/plugins/RT-IR/html/RTIR/Tools/ScriptedAction.html

*** /opt/src/RT-IR-2.4.3/html/RTIR/Tools/ScriptedAction.html 2009-08-18 17:26:46.000000000 +0200
— local/plugins/RT-IR/html/RTIR/Tools/ScriptedAction.html 2010-07-15 13:38:14.000000000 +0200


*** 31,37 ****
<& /Elements/ListActions, actions => @finalresults &>

- --- 31,36 ---- *************** *** 132,137 **** --- 131,144 ---- + + + <&|/l&>Link to incident: + + + + + *************** *** 313,318 **** --- 320,326 ----
      $ARGS{'Subject'} = $original_subject;
      $ARGS{'Content'} = $original_content;
  • $ARGS{'Requestors'} = $addr;
    
        for (qw/Subject Content/) {
            $ARGS{$_} =~ s/_ADDR_/$addr/g;
    

— end of diff —

I noticed this further down:

    my @watchresults = ProcessTicketWatchers(
        TicketObj => $Ticket,
        ARGSRef => { %ARGS, AddRequestor => $addr },
    );

This meant that we could see requestors in investigation tickets OK, but no mail was being sent out! Confusing.

Well - of course, since at the time the ticket was created, the requestor was not specified yet (thus the corresponding Scrip error that no recipients are listed). Later in the loop when the requestor was added this does not trigger any scrips that deal with correspondence! IMO.

Regards,
Gorazd


Gorazd Bozic gorazd.bozic@arnes.si
ARNES SI-CERT, Tehnološki park 18, p.p. 7, SI-1001 Ljubljana, Slovenia
tel: +386 1 479 88 22, fax: +386 1 479 88 23


Rtir mailing list
Rtir@lists.bestpractical.com
http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rtir

Sure! :slight_smile:

— /opt/src/RT-IR-2.4.3/html/RTIR/Tools/ScriptedAction.html 2009-08-18 17:26:46.000000000 +0200
+++ local/plugins/RT-IR/html/RTIR/Tools/ScriptedAction.html 2010-07-15 13:38:14.000000000 +0200
@@ -31,7 +31,6 @@
<& /Elements/ListActions, actions => @finalresults &>

- @@ -132,6 +131,14 @@ + + + <&|/l&>Link to incident: + + + + + @@ -313,6 +320,7 @@
     $ARGS{'Subject'} = $original_subject;
     $ARGS{'Content'} = $original_content;
  • $ARGS{‘Requestors’} = $addr;

     for (qw/Subject Content/) {
         $ARGS{$_} =~ s/_ADDR_/$addr/g;

Hello Gorazd,

I think $addr should be added as requestor only on investigation. Do
you agree here? Actually, the address is added, but late for auto
reply and on create notifications.

Probably the following patch is more apropriate, could you please test it?

diff --git a/html/RTIR/Tools/ScriptedAction.html
b/html/RTIR/Tools/ScriptedAction.html
index 191c176…2e702cd 100644
— a/html/RTIR/Tools/ScriptedAction.html
+++ b/html/RTIR/Tools/ScriptedAction.html
@@ -364,6 +364,7 @@ if ( $ARGS{‘SubmitAction’} ) {
%ARGS,
Queue => $investigationq->Id,
‘new-MemberOf’ => $Incident->Id,

  •        Requestor      => $addr,
       );
       unless ( $Ticket ) {
           Abort("Couldn't launch an Investigation");
    

@@ -373,11 +374,6 @@ if ( $ARGS{‘SubmitAction’} ) {
}
push @finalresults, @ChildActions;

  •    my @watchresults = ProcessTicketWatchers(
    
  •        TicketObj => $Ticket,
    
  •        ARGSRef => { %ARGS, AddRequestor => $addr },
    
  •    );
       my $TemplateObj = RT::Template->new( $session{'CurrentUser'} );
       if ( $ARGS{'Template'} ) {
           $TemplateObj->Load( $ARGS{'Template'} );
    

@@ -424,7 +420,7 @@ if ( $ARGS{‘SubmitAction’} ) {
}

     push @finalresults, map { loc("Ticket [_1]: [_2]", $Ticket->Id, $_) }
  •        @watchresults, @updateresults;
    
  •        @updateresults;
    
       # delete attachments only after they've been sent to everyone
       delete $session{'Attachments'};2010/7/16 Gorazd Božič <gorazd.bozic@arnes.si>:
    

Sure! :slight_smile:

— /opt/src/RT-IR-2.4.3/html/RTIR/Tools/ScriptedAction.html 2009-08-18 17:26:46.000000000 +0200
+++ local/plugins/RT-IR/html/RTIR/Tools/ScriptedAction.html 2010-07-15 13:38:14.000000000 +0200
@@ -31,7 +31,6 @@
<& /Elements/ListActions, actions => @finalresults &>

- @@ -132,6 +131,14 @@ + + + <&|/l&>Link to incident: + + + + + @@ -313,6 +320,7 @@
    $ARGS{'Subject'} = $original_subject;
    $ARGS{'Content'} = $original_content;
  •   $ARGS{'Requestors'} = $addr;
    
      for (qw/Subject Content/) {
          $ARGS{$_} =~ s/_ADDR_/$addr/g;
    

Rtir mailing list
Rtir@lists.bestpractical.com
http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rtir

Best regards, Ruslan.

Hi,

I’ve pushed this into the repo. Will be part of RTIR 2.4.5.2010/7/17 Ruslan Zakirov ruz@bestpractical.com:

Hello Gorazd,

I think $addr should be added as requestor only on investigation. Do
you agree here? Actually, the address is added, but late for auto
reply and on create notifications.

Probably the following patch is more apropriate, could you please test it?

diff --git a/html/RTIR/Tools/ScriptedAction.html
b/html/RTIR/Tools/ScriptedAction.html
index 191c176…2e702cd 100644
— a/html/RTIR/Tools/ScriptedAction.html
+++ b/html/RTIR/Tools/ScriptedAction.html
@@ -364,6 +364,7 @@ if ( $ARGS{‘SubmitAction’} ) {
%ARGS,
Queue => $investigationq->Id,
‘new-MemberOf’ => $Incident->Id,

  •        Requestor      => $addr,
      );
      unless ( $Ticket ) {
          Abort("Couldn't launch an Investigation");
    

@@ -373,11 +374,6 @@ if ( $ARGS{‘SubmitAction’} ) {
}
push @finalresults, @ChildActions;

  •    my @watchresults = ProcessTicketWatchers(
    
  •        TicketObj => $Ticket,
    
  •        ARGSRef => { %ARGS, AddRequestor => $addr },
    
  •    );
    
  •   my $TemplateObj = RT::Template->new( $session{'CurrentUser'} );
      if ( $ARGS{'Template'} ) {
          $TemplateObj->Load( $ARGS{'Template'} );
    

@@ -424,7 +420,7 @@ if ( $ARGS{‘SubmitAction’} ) {
}

    push @finalresults, map { loc("Ticket [_1]: [_2]", $Ticket->Id, $_) }
  •        @watchresults, @updateresults;
    
  •        @updateresults;
    
      # delete attachments only after they've been sent to everyone
      delete $session{'Attachments'};
    

2010/7/16 Gorazd Božič gorazd.bozic@arnes.si:

Sure! :slight_smile:

— /opt/src/RT-IR-2.4.3/html/RTIR/Tools/ScriptedAction.html 2009-08-18 17:26:46.000000000 +0200
+++ local/plugins/RT-IR/html/RTIR/Tools/ScriptedAction.html 2010-07-15 13:38:14.000000000 +0200
@@ -31,7 +31,6 @@
<& /Elements/ListActions, actions => @finalresults &>

- @@ -132,6 +131,14 @@ + + + <&|/l&>Link to incident: + + + + + @@ -313,6 +320,7 @@
    $ARGS{'Subject'} = $original_subject;
    $ARGS{'Content'} = $original_content;
  •   $ARGS{'Requestors'} = $addr;
    
      for (qw/Subject Content/) {
          $ARGS{$_} =~ s/_ADDR_/$addr/g;
    

Rtir mailing list
Rtir@lists.bestpractical.com
http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rtir


Best regards, Ruslan.

Best regards, Ruslan.