[Catalyst] problem with sending email
JOUANNE Mickael
mickael at gandi.net
Thu Jan 5 14:55:18 CET 2006
Hi.
I want to make a controller for sending mail.
But the problem is that $c->forward('render_email') return me the stash
hash and not the processing of my template.
It it normal ?
Do I forgot to do something in my code ?
My inspiration was the snippet in Catalyst::Plugin::Email
Here is my Classes :
Myapp.pm:
sub end : Private {
...
unless ( $c->response->body ) {
$c->forward('View::TT');
}
}
Myapp::Controller:MyController.pm:
...
sub update : Local {
...
my $options = { From => 'from at yahoo.fr', To => 'to at yahoo.fr',
Subject => "Subject", tmpl => 'mail.txt' };
# send an email to the customer
$c->subreq("/mail/send_email", $options);
# continue for display the page in browser
$c->stash->{page} = { $page };
$c->stash->{template} = 'update.html';
}
Myapp::Controller::Mail.pm:
sub send_email : Private {
my MIME::Lite->new(
...
Data => $c->forward('render_email'),
);
}
sub render_email : Private {
my ( $self, $c ) = @_;
$c->stash(
template => $c->stash->{tmpl},
);
}
Thanks a lot.
--
Mickaël JOUANNE // email: mickael at gandi.net
Gandi
* If Linux doesn't have the solution, you have the wrong problem *
More information about the Catalyst
mailing list