[Catalyst] Sending email

Dave Richards david at sonic.net.au
Tue Apr 3 05:35:37 GMT 2007


Thanks muchly, I needed a '.tt2' on the end of the filename specification.

Thanks,  Dave

Jason Kohles wrote:
> On Apr 2, 2007, at 6:10 AM, Dave Richards wrote:
> 
>> Hi all,
>>
>> To get the first obvious point out of the way, yes, I'm a newbie to 
>> Catalyst...
>>
>> I have developed a good little app, on the way to a much larger app 
>> using Catalyst, and it is all going along great....then, I decided to 
>> add email notifications to the system, that's when I have come unstuck.
>>
>> I really am still getting my head around Catalyst, so I apologise if 
>> this is a really dumb question.  I need to send an email from within a 
>> function, here is the code snippet:
>>
>> $c->email(
>>     header => [
>>         To => $result->params->{email},
>>         Subject => 'User Registration' ],
>>     body => $c->view('TT')->render($c,'email/registered'),
>> );
>>
>> And here is the error message:
>>
>> Caught exception in Arkadia::Controller::Users->register_do "Not a 
>> SCALAR reference at /Library/Perl/5.8.6/Email/Simple.pm line 195."
>>
> I would suspect that render is returning a Template::Exception object, 
> and since you aren't checking the return value, you are passing that on 
> to Email::Simple, which doesn't know what to do with it...
> 
> my $body = $c->view( 'TT' )->render( $c, 'email/registered' );
> if ( ref $body && $body->isa( 'Template::Exception' ) ) {
>     die "Rendering template failed! ($body)";
> }
> 
> $c->email(
>     header => [
>         To => $result->params->{email},
>         Subject => 'User Registration',
>     ],
>     body => $body,
> );
> 
> 
> --Jason Kohles
> email at jasonkohles.com
> http://www.jasonkohles.com/
> "A witty saying proves nothing."  -- Voltaire
> 
> 
> 
> _______________________________________________
> List: Catalyst at lists.rawmode.org
> Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
> Dev site: http://dev.catalyst.perl.org/
> 



More information about the Catalyst mailing list