Send Mail Scrip problems

Hi,

I am trying to use the example here:

http://wiki.bestpractical.com/view/SendEmailAction

to send emails based on custom conditions. I have this working using
hard coded destination mail addresses but when I try and use the
section in the template as described in the wiki:

$GroupObj->LoadUserDefinedGroup(‘Group Name’);
$GroupObj->MemberEmailAddressesAsString()}

it doesn’t work for me, I see this error in the system messages file:

Mar 16 00:01:52 alpha RT: RT::Users=HASH(0x16b0a97c) was created
without a CurrentUser. Any RT object which is subclass of RT::Base
must be created with a RT::CurrentUser or a RT::User object as the
first argument. (/usr/local/lib/perl5/site_perl/5.8.9/RT/Base.pm:108)
Mar 16 00:01:53 alpha RT: Template parsing error:
RT::Users=HASH(0x16b0a97c) was created without a CurrentUser at
/usr/local/lib/perl5/site_perl/5.8.9/RT/SearchBuilder.pm line 81
RT::SearchBuilder::_Init(‘RT::Users=HASH(0x16b0a97c)’, undef) called
at /usr/local/lib/perl5/site_perl/5.8.9/RT/Users_Overlay.pm line 80
RT::Users::_Init(‘RT::Users=HASH(0x16b0a97c)’, undef) called at
/usr/local/lib/perl5/site_perl/5.8.9/DBIx/SearchBuilder.pm line 93
DBIx::SearchBuilder::new(‘RT::Users’, undef) called at
/usr/local/lib/perl5/site_perl/5.8.9/RT/Group_Overlay.pm line 843
RT::Group::UserMembersObj(‘RT::Group=HASH(0x16b327ac)’) called at
/usr/local/lib/perl5/site_perl/5.8.9/RT/Group_Overlay.pm line 878
RT::Group::MemberEmailAddresses(‘RT::Group=HASH(0x16b327ac)’) called
at /usr/local/lib/perl5/site_perl/5.8.9/RT/Group_Overlay.pm line 899

RT::Group::MemberEmailAddressesAsString(‘RT::Group=HASH(0x16b327ac)’)
called at template line 3 eval 'package Text::Template::GEN2;
; #line 1 template my $GroupObj = RT::Group->new
Mar 16 00:01:53 alpha kernel: oup->new

Can anyone help? What is going wrong? This is on RT 3.8.2,

thanks for any help, Andy.

Hi,

On RT 3.8.2 I am trying to use the example here:

http://wiki.bestpractical.com/view/SendEmailAction

When I try and use the section in the template as described in the wiki:

$GroupObj->LoadUserDefinedGroup(‘Group Name’);
$GroupObj->MemberEmailAddressesAsString()}

it doesn’t work for me, I see this error in the system messages file:

Mar 16 00:01:52 alpha RT: RT::Users=HASH(0x16b0a97c) was created
without a CurrentUser. Any RT object which is subclass of RT::Base
must be created with a RT::CurrentUser or a RT::User object as the
first argument. (/usr/local/lib/perl5/site_perl/5.8.9/RT/Base.pm:108)
Mar 16 00:01:53 alpha RT: Template parsing error:
RT::Users=HASH(0x16b0a97c) was created without a CurrentUser at
/usr/local/lib/perl5/site_perl/5.8.9/RT/SearchBuilder.pm line 81
RT::SearchBuilder::_Init(‘RT::Users=HASH(0x16b0a97c)’, undef) called
at /usr/local/lib/perl5/site_perl/5.8.9/RT/Users_Overlay.pm line 80
RT::Users::_Init(‘RT::Users=HASH(0x16b0a97c)’, undef) called at
/usr/local/lib/perl5/site_perl/5.8.9/DBIx/SearchBuilder.pm line 93
DBIx::SearchBuilder::new(‘RT::Users’, undef) called at
/usr/local/lib/perl5/site_perl/5.8.9/RT/Group_Overlay.pm line 843
RT::Group::UserMembersObj(‘RT::Group=HASH(0x16b327ac)’) called at
/usr/local/lib/perl5/site_perl/5.8.9/RT/Group_Overlay.pm line 878
RT::Group::MemberEmailAddresses(‘RT::Group=HASH(0x16b327ac)’) called
at /usr/local/lib/perl5/site_perl/5.8.9/RT/Group_Overlay.pm line 899

RT::Group::MemberEmailAddressesAsString(‘RT::Group=HASH(0x16b327ac)’)
called at template line 3 eval 'package Text::Template::GEN2;
; #line 1 template my $GroupObj = RT::Group->new
Mar 16 00:01:53 alpha kernel: oup->new

It does work if I use this code:

$GroupObj->LoadUserDefinedGroup(‘Group Name’);
$GroupObj->MemberEmailAddressesAsString()}

But I don’t understand the difference, is using $RT::SystemUser going
to do anything bad? If this is ok and there is some problem with the
code as is on the wiki should I update the data on the wiki?

thanks for any help, Andy.

Andy,

Did you remember to insert a "blank" line after the "to:" line. When 

you replace “Subject:”, “From:”, or “to:” (header replacement line) you
MUST insert a blank line between them and the body of your template.
Hope this helps.

Kenn
LBNLOn 3/15/2009 4:53 PM, Andy Smith wrote:

Hi,

I am trying to use the example here:

SendEmailAction - Request Tracker Wiki

to send emails based on custom conditions. I have this working using
hard coded destination mail addresses but when I try and use the
section in the template as described in the wiki:

To: { my $GroupObj = RT::Group->new($user);
$GroupObj->LoadUserDefinedGroup(‘Group Name’);
$GroupObj->MemberEmailAddressesAsString()}

it doesn’t work for me, I see this error in the system messages file:

Mar 16 00:01:52 alpha RT: RT::Users=HASH(0x16b0a97c) was created
without a CurrentUser. Any RT object which is subclass of RT::Base
must be created with a RT::CurrentUser or a RT::User object as the
first argument. (/usr/local/lib/perl5/site_perl/5.8.9/RT/Base.pm:108)
Mar 16 00:01:53 alpha RT: Template parsing error:
RT::Users=HASH(0x16b0a97c) was created without a CurrentUser at
/usr/local/lib/perl5/site_perl/5.8.9/RT/SearchBuilder.pm line 81
RT::SearchBuilder::_Init(‘RT::Users=HASH(0x16b0a97c)’, undef) called
at /usr/local/lib/perl5/site_perl/5.8.9/RT/Users_Overlay.pm line 80
RT::Users::_Init(‘RT::Users=HASH(0x16b0a97c)’, undef) called at
/usr/local/lib/perl5/site_perl/5.8.9/DBIx/SearchBuilder.pm line 93
DBIx::SearchBuilder::new(‘RT::Users’, undef) called at
/usr/local/lib/perl5/site_perl/5.8.9/RT/Group_Overlay.pm line 843
RT::Group::UserMembersObj(‘RT::Group=HASH(0x16b327ac)’) called at
/usr/local/lib/perl5/site_perl/5.8.9/RT/Group_Overlay.pm line 878
RT::Group::MemberEmailAddresses(‘RT::Group=HASH(0x16b327ac)’) called
at /usr/local/lib/perl5/site_perl/5.8.9/RT/Group_Overlay.pm line 899

RT::Group::MemberEmailAddressesAsString(‘RT::Group=HASH(0x16b327ac)’)
called at template line 3 eval 'package Text::Template::GEN2;
; #line 1 template my $GroupObj = RT::Group->new
Mar 16 00:01:53 alpha kernel: oup->new

Can anyone help? What is going wrong? This is on RT 3.8.2,

thanks for any help, Andy.


The rt-users Archives

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,

thanks for replying. Actually I seem to have found a way to get it
working but without really understanding what I have done :P. Please
see my second post with the issue described slightly more clearly (I
think).

http://lists.bestpractical.com/pipermail/rt-users/2009-March/058001.html

If you have any ideas what I have done any why it works with the later
config it would be great to know!

Thanks Andy.

Quoting Ken Crocker kfcrocker@lbl.gov:

Maybe the $user that you use to initialize the Group Object variable is not initialized properly.
I always use $RT::SystemUser instead of the CurrentUser to initialize such variables, but until now I havent really thought about it being ‘bad’.

Any thoughts about this?

-AshishFrom: rt-users-bounces@lists.bestpractical.com [rt-users-bounces@lists.bestpractical.com] On Behalf Of Andy Smith [a.smith@ukgrid.net]
Sent: Tuesday, March 17, 2009 11:01 PM
To: Ken Crocker
Cc: rt-users@lists.bestpractical.com
Subject: Re: [rt-users] Send Mail Scrip problems

Hi Ken,

thanks for replying. Actually I seem to have found a way to get it
working but without really understanding what I have done :P. Please
see my second post with the issue described slightly more clearly (I
think).

http://lists.bestpractical.com/pipermail/rt-users/2009-March/058001.html

If you have any ideas what I have done any why it works with the later
config it would be great to know!

Thanks Andy.

Quoting Ken Crocker kfcrocker@lbl.gov:

Andy,

Did you remember to insert a “blank” line after the “to:” line.
When you replace “Subject:”, “From:”, or “to:” (header replacement
line) you MUST insert a blank line between them and the body of your
template.
Hope this helps.

Kenn
LBNL

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