[Catalyst] Sending email
Jason Kohles
email at jasonkohles.com
Mon Apr 2 21:10:42 GMT 2007
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
More information about the Catalyst
mailing list