[Catalyst] [Beginner] C::V::Email::Template does not render
Ekki Plicht (DF4OR)
ep at plicht.de
Sun Sep 12 20:14:04 GMT 2010
Hi.
Following the example in THE BOOK (cookbook part) I try to get my user
registration process to work. I use C::V::Email::Template, and all seems to
work fine, according to the debug output [1], see below.
The mail does get sent, but it is not rendered proprly. The very simple mail
template looks like this:
[% c.localize('mm_reghello') %]
[% c.localize('mm_regsent') %]
[% c.uri_for('/user/registration') %]/[% c.digest %]
[% c.localize('mm_regfinal') %]
[% PROCESS mailsig.tt %]
What I receive as mail is:
mm_reghello
mm_regsent
http://localhost:3000/user/registration/
mm_regfinal
--
The mail signature as intended.
I.e. the localization does not work (it does fine on the web templates) and
the digest code is missing after the URI. The placeholders 'mm_*' are all
defined and available in various .po files. Other stash variables, which I put
into the mail template for testing pruposes, are also missing in the rendered
output.
My registration action looks like this:
sub register :Local {
my ( $self, $c ) = @_;
if ( exists($c->req->params->{'email'}) ) {
my $newuser;
eval {
$newuser= $c->model('WSDB::register')->create({
email => $c->req->params->{'email'}
})
};
if ($@) {
$c->log->debug( "Email::Valid failed" );
$c->stash( errors => { email => 'ee_invalid' }, err => $@ );
return; # redraw
}
else {
# Mail ok, send mail
$c->stash->{digest} = $newuser->get_column('digest');
$c->stash->{mailto} = $c->req->params->{'email'};
$c->stash->{mailsubj} = 'mm_registersubject';
$c->stash->{mailtemplate} = 'registermail.tt';
$c->forward( '/email' );
return $c->res->redirect( $c->uri_for('/user/registerdone') );
}
}
}
I.e. the successful (mail is valid) register request is answered with a
forward to sending the mail, then the user/registerdone action is kicking in.
That all works, but as I said, the mail is not rendered correctly.
The /email action is in the root controller like this:
sub email : Private {
my ( $self, $c ) = @_;
$c->stash->{email} = {
to => $c->stash->{mailto},
from => $c->config->{mailfrom},
subject => $c->stash->{mailsubj},
template => $c->stash->{mailtemplate}
};
$c->forward( $c->view('Email::Template') );
}
Probably this could all be done better, but I followed the cookbook example so
far.
What am I missing? Thanks for any hints where I can continue looking.
Cheers,
Ekki
[1] Debug output from dev server
--------------------------------
[info] *** Request 15 (0.001/s) [12344] [Sun Sep 12 21:56:22 2010] ***
[debug] "POST" request for "user/register" from "127.0.0.1"
[debug] Body Parameters are:
.-------------------------------------+--------------------------------------.
| Parameter | Value |
+-------------------------------------+--------------------------------------+
| email | ekki at plicht.de |
'-------------------------------------+--------------------------------------'
[debug] Path is "user/register"
[debug] C::V::Email::Template uses Catalysts default view
wshop::View::Web=HASH(0x94b41f8) for rendering.
[debug] C::V::Email uses default content_type text/plain.
[debug] Rendering template "registermail.tt"
[debug] C::V::Email uses specified content_type text/plain.
[debug] Redirecting to "http://localhost:3000/user/registerdone"
[debug] Response Code: 302; Content-Type: text/html; charset=utf-8; Content-
Length: unknown
[info] Request took 1.981418s (0.505/s)
.------------------------------------------------------------+-----------.
| Action | Time |
+------------------------------------------------------------+-----------+
| /user/register | 1.952326s |
| -> /email | 1.194451s |
| -> wshop::View::Email::Template->process | 1.193180s |
| /end | 0.000637s |
'------------------------------------------------------------+-----------'
[info] *** Request 16 (0.001/s) [12344] [Sun Sep 12 21:56:24 2010] ***
[debug] "GET" request for "user/registerdone" from "127.0.0.1"
[debug] Path is "user/registerdone"
[debug] Rendering template "user/registerdone.tt"
[debug] Response Code: 200; Content-Type: text/html; charset=utf-8; Content-
Length: 5656
[info] Request took 0.051840s (19.290/s)
.------------------------------------------------------------+-----------.
| Action | Time |
+------------------------------------------------------------+-----------+
| /user/registerdone | 0.000238s |
| /end | 0.036513s |
| -> wshop::View::Web->process | 0.035203s |
'------------------------------------------------------------+-----------'
More information about the Catalyst
mailing list