Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Catalyst::View::Email::Template - "no sender"

by kwaping (Priest)
on Jul 30, 2010 at 01:44 UTC ( #852027=perlquestion: print w/replies, xml ) Need Help??
kwaping has asked for the wisdom of the Perl Monks concerning the following question:

I keep getting a "no sender" error when trying to send email via Catalyst::View::Email::Template. I'm pretty sure it's some sort of config error, but I have tried everything I can think of with no resolution. Please take a gander at my config and code and tell me what you think I should do. Thanks!

Here's the code that sends the email:
my $to = $user->email; $c->stash->{email_out} = { to => $to, subject => " Membership Activation ($enc_string)", template => '', }; $c->forward($c->view('Email::Template')); if (not scalar @{$c->error}) { $c->log->debug("*** Email sent! $to ($enc_string) ***"); }
From (not its real name, but the equivalent):
__PACKAGE__->config->{'View::Email::Template'} = { template_prefix => 'emails', stash_key => 'email_out', default => { view => 'TT', content_type => 'text/plain', charset => 'utf-8', }, sender => { mailer => 'SMTP', mailer_args => { host => 'mail.<mydomain>.com', sasl_username => '<email address here>', sasl_password => '<email password here>', ssl => 1, } }, };
I have no config for View::Email because I don't plan on sending any non-templated emails. I've tried it with and without, no change. I also have no config directly in either my View::Email or View::Email::Template modules. I tried putting some in there but it didn't resolve the issue. Here's some of the debug output from Catalyst:
[debug] Path is "send_activation_email" [debug] Arguments are "<username goes here>" [debug] *** Manually sending activation email *** [debug] *** Sending activation email *** [debug] *** Found existing activation, 3 *** [debug] C::V::Email::Template uses default view XXX::View::TT=HASH(0x1 +0238e1c0) for rendering. [debug] C::V::Email uses default content_type text/plain. [debug] Rendering template "emails/" [debug] C::V::Email uses specified content_type text/plain. [error] no sender
I will post more debug output upon request, but there's nothing in there that appears useful, to my eyes.

Update: Solved! It appears that I was mis-interpreting the "no sender" error as being a config error. It was actually referring to the fact that I had not specified a "from" parameter. (I assumed it would use the "sender" values as a default.) Thanks to Oleg Kostyuk on the Catalyst mailing list for the fix!

It's all fine and dandy until someone has to look at the code.