[Dancer-users] Dancer::Plugin::Email problem with checking email failures
Assaf Gordon
gordon at cshl.edu
Mon Sep 12 21:23:24 CEST 2011
Hello,
I'm having problems checking the return status of email sending with "Dancer::Plugin::Email" .
The first example in the "code recipes" of "Dancer::Plugin::Email" shows the following:
----
post '/contact' => sub {
my $msg = email {
to => '...',
subject => '...',
message => $msg,
encoding => 'base64',
attach => [ '/path/to/file' ]
};
warn $msg->{string} if $msg->{type} eq 'failure';
};
----
This is the actual code I used:
---
get '/emailtest' => sub {
my $msg = email {
to => 'gordon\@cshl.edu',
subject => 'Dancer::PlugIn::Email Test',
message => "Hello World from Dancer::Plugin::Email",
};
warn $msg->{string} if $msg->{type} eq 'failure';
return "Email Sent!\n";
};
---
This is the error I get:
------------
Warning caught during route execution: Use of uninitialized value in string eq at /home/gordon/projects/perl_dancer_test/user_email_verification/lib/user_email_verification.pm line 80.
/home/gordon/projects/perl_dancer_test/user_email_verification/lib/user_email_verification.pm around line 80
77 subject => 'Dancer::PlugIn::Email Test',
78 message => "Hello World from Dancer::Plugin::Email",
79 };
80 warn $msg->{string} if $msg->{type} eq 'failure';
81 return "Email Sent!\n";
82 };
83
-----------
Trying to dig a little deeper, it seems "$msg" is a "Return::Value" object, and that class is deprecated.
Also, "$msg->{type}" returns an empty string (so it's not the problem), but "$msg->{string}" returns undef.
and "Data::Dumper($msg)" gives:
-----
$VAR1 = bless( {
'prop' => {},
'string' => 'success',
'type' => 'success',
'errno' => undef
}, 'Return::Value' );
----
I'm using Perl 5.10.1 , Dancer 1.3702, Dancer::Plugin::Email 0.1300 .
Any suggestions how to solve this ?
Thanks!
-gordon
More information about the Dancer-users
mailing list