Scrip does not send email

Hi all,
I am having a problem with a scrip that does not send emails as expected.

I have a queue with a mandatory custom field. If a user tries to create a ticket in that queue from the RT interface without populating the cf, RT will complain. However, if a user creates the ticket by sending an email RT will happily create it.

So I created a scrip on that queue that checks if a mandatory cf is present, and if it is - and it is not populated - it will put the ticket in status “rejected”.

Settings are:

Condition: User Defined
Action: Notify Requestors
Template: Global template: Error: no mandatory CF
Stage: TransactionBatch
Custom Condition:
my $trans = $self->TransactionObj;
return 0 unless $trans->Type eq “Create”;

my $ticket = $self->TicketObj;

my $CustomFields = $ticket->QueueObj->TicketCustomFields();
while (my $CustomField = $CustomFields->Next()) {
my $nam = $CustomField->Name;
my $typ = $CustomField->Type;
my $vad = $CustomField->Pattern;

$RT::Logger->info( ">  CustomField: $nam \n" );
$RT::Logger->info( ">  CustomField: $typ \n" );
$RT::Logger->info( ">  CustomField: $vad \n" );

if ($vad = '(?#Mandatory)') {
    my $val = $ticket->FirstCustomFieldValue($nam);
    if ($val ne '') {
        return 0;
    } else {
        $ticket->SetStatus("rejected");
    }
}

}

return 1;

The scrip works as expected, but it will not send the email to the requestor. In the log I see this:

49587 - Scrip 28 OnCreateCheckCF (/opt/rtschedu/bin/…/lib/RT/Action/SendEmail.pm:302)
[Thu Jun 11 07:53:27 2009] [info]: <rt-3.8.4-8458-1244706807-1237.3505-28-0@Bankadati S.I.> No recipients found. Not sending. (/opt/rtschedu/bin/…/lib/RT/Interface/Email.pm:338)

I can not understand why it is saying “No recipients found”. Any ideas?

TIA
Bye
Cris

Guadagnino,

From what I can see, the scrip did TRY to send an Email. So the 

action /did/ work. I would look at the privileges for the requestor. If
RT tries to send an Email and the Requestor doesn’t have the right to
GET Emails, then RT won’t find a recipient. I’m not sure, but I think
"watch" would be a right o look at. There may be others, but look in
that direction. BTW, did the ticket status get changed to “rejected”?

Kenn
LBNLOn 6/11/2009 1:44 AM, Guadagnino Cristiano wrote:

Hi all,

I am having a problem with a scrip that does not send emails as expected.

I have a queue with a mandatory custom field. If a user tries to
create a ticket in that queue from the RT interface without populating
the cf, RT will complain. However, if a user creates the ticket by
sending an email RT will happily create it.

So I created a scrip on that queue that checks if a mandatory cf is
present, and if it is - and it is not populated - it will put the
ticket in status “rejected”.

Settings are:

Condition: User Defined

Action: Notify Requestors

Template: Global template: Error: no mandatory CF

Stage: TransactionBatch

Custom Condition:

my $trans = $self->TransactionObj;

return 0 unless $trans->Type eq “Create”;

my $ticket = $self->TicketObj;

my $CustomFields = $ticket->QueueObj->TicketCustomFields();

while (my $CustomField = $CustomFields->Next()) {

my $nam = $CustomField->Name;

my $typ = $CustomField->Type;

my $vad = $CustomField->Pattern;



$RT::Logger->info( ">  CustomField: $nam \n" );

$RT::Logger->info( ">  CustomField: $typ \n" );

$RT::Logger->info( ">  CustomField: $vad \n" );



if ($vad = '(?#Mandatory)') {

    my $val = $ticket->FirstCustomFieldValue($nam);

    if ($val ne '') {

        return 0;

    } else {

        $ticket->SetStatus("rejected");

    }

}

}

return 1;

The scrip works as expected, but it will not send the email to the
requestor. In the log I see this:

49587 - Scrip 28 OnCreateCheckCF
(/opt/rtschedu/bin/…/lib/RT/Action/SendEmail.pm:302)

[Thu Jun 11 07:53:27 2009] [info]:
<rt-3.8.4-8458-1244706807-1237.3505-28-0@Bankadati S.I.> No recipients
found. Not sending. (/opt/rtschedu/bin/…/lib/RT/Interface/Email.pm:338)

I can not understand why it is saying “No recipients found”. Any ideas?

TIA

Bye

Cris



http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Community help: http://wiki.bestpractical.com
Commercial support: sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com

Hi Ken!

Yes, the ticket status got changed to “rejected”.
I’ll look at the rights, but that same user receives a notification email if I “take” one of his tickets, so I’m inclined to think the problem is elsewhere.

Thank you!

Bye
Cris

Da: Ken Crocker [mailto:kfcrocker@lbl.gov]
Inviato: giovedì 11 giugno 2009 16.41
A: Guadagnino Cristiano
Oggetto: Re: [rt-users] Scrip does not send email

Guadagnino,

From what I can see, the scrip did TRY to send an Email. So the action did work. I would look at the privileges for the requestor. If RT tries to send an Email and the Requestor doesn't have the right to GET Emails, then RT won't find a recipient. I'm not sure, but I think "watch" would be a right o look at. There may be others, but look in that direction. BTW, did the ticket status get changed to "rejected"?

Kenn
LBNLOn 6/11/2009 1:44 AM, Guadagnino Cristiano wrote:
Hi all,
I am having a problem with a scrip that does not send emails as expected.

I have a queue with a mandatory custom field. If a user tries to create a ticket in that queue from the RT interface without populating the cf, RT will complain. However, if a user creates the ticket by sending an email RT will happily create it.

So I created a scrip on that queue that checks if a mandatory cf is present, and if it is - and it is not populated - it will put the ticket in status “rejected”.

Settings are:

Condition: User Defined
Action: Notify Requestors
Template: Global template: Error: no mandatory CF
Stage: TransactionBatch
Custom Condition:
my $trans = $self->TransactionObj;
return 0 unless $trans->Type eq “Create”;

my $ticket = $self->TicketObj;

my $CustomFields = $ticket->QueueObj->TicketCustomFields();
while (my $CustomField = $CustomFields->Next()) {
my $nam = $CustomField->Name;
my $typ = $CustomField->Type;
my $vad = $CustomField->Pattern;

$RT::Logger->info( ">  CustomField: $nam \n" );
$RT::Logger->info( ">  CustomField: $typ \n" );
$RT::Logger->info( ">  CustomField: $vad \n" );

if ($vad = '(?#Mandatory)') {
    my $val = $ticket->FirstCustomFieldValue($nam);
    if ($val ne '') {
        return 0;
    } else {
        $ticket->SetStatus("rejected");
    }
}

}

return 1;

The scrip works as expected, but it will not send the email to the requestor. In the log I see this:

49587 - Scrip 28 OnCreateCheckCF (/opt/rtschedu/bin/…/lib/RT/Action/SendEmail.pm:302)
[Thu Jun 11 07:53:27 2009] [info]: <rt-3.8.4-8458-1244706807-1237.3505-28-0@Bankadati S.I.>mailto:rt-3.8.4-8458-1244706807-1237.3505-28-0@BankadatiS.I. No recipients found. Not sending. (/opt/rtschedu/bin/…/lib/RT/Interface/Email.pm:338)

I can not understand why it is saying “No recipients found”. Any ideas?

TIA
Bye
Cris

http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Community help: http://wiki.bestpractical.com

Commercial support: sales@bestpractical.commailto:sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.

Buy a copy at http://rtbook.bestpractical.com

Guad,

IF that person /IS/ getting other emails, is it from the same queue? 

But I think you’re right. It is somewhere else, but NOT the scrip. The
scrip is fine.

Kenn
LBNLOn 6/11/2009 7:46 AM, Guadagnino Cristiano wrote:

Hi Ken!

Yes, the ticket status got changed to “rejected”.

I’ll look at the rights, but that same user receives a notification
email if I “take” one of his tickets, so I’m inclined to think the
problem is elsewhere.

Thank you!

Bye

Cris

Da: Ken Crocker [mailto:kfcrocker@lbl.gov]
Inviato: gioved� 11 giugno 2009 16.41
A: Guadagnino Cristiano
Cc: rt-users@lists.bestpractical.com
Oggetto: Re: [rt-users] Scrip does not send email

Guadagnino,

From what I can see, the scrip did TRY to send an Email. So the 

action /did/ work. I would look at the privileges for the requestor.
If RT tries to send an Email and the Requestor doesn’t have the right
to GET Emails, then RT won’t find a recipient. I’m not sure, but I
think “watch” would be a right o look at. There may be others, but
look in that direction. BTW, did the ticket status get changed to
"rejected"?

Kenn
LBNL

On 6/11/2009 1:44 AM, Guadagnino Cristiano wrote:

Hi all,

I am having a problem with a scrip that does not send emails as expected.

I have a queue with a mandatory custom field. If a user tries to
create a ticket in that queue from the RT interface without populating
the cf, RT will complain. However, if a user creates the ticket by
sending an email RT will happily create it.

So I created a scrip on that queue that checks if a mandatory cf is
present, and if it is - and it is not populated - it will put the
ticket in status “rejected”.

Settings are:

Condition: User Defined

Action: Notify Requestors

Template: Global template: Error: no mandatory CF

Stage: TransactionBatch

Custom Condition:

my $trans = $self->TransactionObj;

return 0 unless $trans->Type eq “Create”;

my $ticket = $self->TicketObj;

my $CustomFields = $ticket->QueueObj->TicketCustomFields();

while (my $CustomField = $CustomFields->Next()) {

my $nam = $CustomField->Name;

my $typ = $CustomField->Type;

my $vad = $CustomField->Pattern;



$RT::Logger->info( ">  CustomField: $nam \n" );

$RT::Logger->info( ">  CustomField: $typ \n" );

$RT::Logger->info( ">  CustomField: $vad \n" );



if ($vad = '(?#Mandatory)') {

    my $val = $ticket->FirstCustomFieldValue($nam);

    if ($val ne '') {

        return 0;

    } else {

        $ticket->SetStatus("rejected");

    }

}

}

return 1;

The scrip works as expected, but it will not send the email to the
requestor. In the log I see this:

49587 - Scrip 28 OnCreateCheckCF
(/opt/rtschedu/bin/…/lib/RT/Action/SendEmail.pm:302)

[Thu Jun 11 07:53:27 2009] [info]:
<rt-3.8.4-8458-1244706807-1237.3505-28-0@Bankadati S.I.>
mailto:rt-3.8.4-8458-1244706807-1237.3505-28-0@BankadatiS.I. No
recipients found. Not sending.
(/opt/rtschedu/bin/…/lib/RT/Interface/Email.pm:338)

I can not understand why it is saying “No recipients found”. Any ideas?

TIA

Bye

Cris



http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Community help: http://wiki.bestpractical.com
Commercial support: sales@bestpractical.com mailto:sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com

Hi,
I want to let everybody know that I solved my problem: I had to change the action from “Notify requestors” to “Autoreply to requestors”. Don’t ask me why, but this is working wonderfully now. I’ll add this to the wiki just in case someone wants to follow the same route (rejecting mail-generated tickets if a mandatory CF is missing).

Bye
Cris

Da: Ken Crocker [mailto:kfcrocker@lbl.gov]
Inviato: giovedì 11 giugno 2009 17.17
A: Guadagnino Cristiano
Oggetto: Re: R: [rt-users] Scrip does not send email

Guad,

IF that person IS getting other emails, is it from the same queue? But I think you're right. It is somewhere else, but NOT the scrip. The scrip is fine.

Kenn
LBNLOn 6/11/2009 7:46 AM, Guadagnino Cristiano wrote:
Hi Ken!

Yes, the ticket status got changed to “rejected”.
I’ll look at the rights, but that same user receives a notification email if I “take” one of his tickets, so I’m inclined to think the problem is elsewhere.

Thank you!

Bye
Cris