[Catalyst] C::V::Email::Template cannot send data ...
Kiffin Gish
kiffin.gish at planet.nl
Sat Jan 9 15:53:20 GMT 2010
Been struggling most of the afternoon trying to figure this out but to
no avail, hopefully someone can help me.
For registration of new users I've decided to expand upon the MojoMojo
example, using Catalyst::View::Email::Template. Trying to send email
results in the following error:
The following error(s) occurred: Caught exception in
MyApp::View::Email::Template->process "Can't send data
at /usr/local/share/perl/5.10.0/Catalyst/Action.pm line 65"
The lib/MyApp/View/Email/Template.pm file looks like this:
-----
package MyApp::View::Email::Template;
use strict;
use base 'Catalyst::View::Email::Template';
-----
In MyApp.pm I have:
-----
__PACKAGE__->config(
'View::Email::Template' => {
stash_key => 'email',
template_prefix => 'mail',
sender => {
mailer => 'SMTP',
},
}
);
In my Registration controller action register I've got:
-----
$c->stash(
secret => md5_hex( $user->email . $c->pref('entropy') ),
email => {
from => 'kiffin.gish at planet.nl',
to => 'kiffin.gish at planet.nl',
subject => $c->pref('name') . ' Registration request',
template => 'register.tt2',
},
$c->forward( $c->view('Email::Template') );
if ( scalar( @{ $c->error } ) ) {
$c->stash->{error_message} = 'The following error(s) occurred: ' .
join(', ', @{ $c->error } );
$c->clear_errors;
return;
}
The template is located in root/src/mail/register.tt2, and in Myapp.pm:
-----
__PACKAGE__->config(
'View::TT' => {
TEMPLATE_EXTENSION => '.tt2',
INCLUDE_PATH => [
I4::Web->path_to( 'root', 'src' ),
I4::Web->path_to( 'root', 'src', 'page' ),
I4::Web->path_to( 'root', 'lib' ),
],
...
I made a simple test script to verify that indeed I can send email and
it works fine:
-----
#!/usr/bin/perl
use strict;
use warnings;
use Email::Send;
my $message = <<'__MESSAGE__';
To: kiffin.gish at planet.nl
From: kiffin.gish at planet.nl
Subject: Test email
This is a boring test email.
__MESSAGE__
my $sender = Email::Send->new({mailer => 'SMTP'});
$sender->mailer_args([Host => 'localhost']);
$sender->send($message);
-----
Am very curious if anyone can spot the problem.
--
Kiffin Gish <Kiffin.Gish at planet.nl>
Gouda, The Netherlands
More information about the Catalyst
mailing list