<div dir="ltr">That kind of looks like a message from Email::Stuffer or one of its dependencies. <div><br></div><div>You might want to wrap '<span style="font-family:arial,sans-serif;font-size:13px">send_out_mail' or '</span><span style="font-family:arial,sans-serif;font-size:13px">Email::Stuffer->from' in a eval or try block like:</span></div>
<div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><font face="arial, sans-serif">try {</font></div><div><font face="arial, sans-serif"> </font><span style="font-family:arial,sans-serif;font-size:13px">Email::Stuffer->from(...);</span></div>
<div><font face="arial, sans-serif">}</font></div><div><font face="arial, sans-serif">catch {</font></div><div><font face="arial, sans-serif"> error "Failed to call </font><span style="font-family:arial,sans-serif;font-size:13px">Email::Stuffer->from: $_";</span></div>
<div><font face="arial, sans-serif">};</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><br></font></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Sat, Apr 26, 2014 at 3:08 AM, Hugues <span dir="ltr"><<a href="mailto:hugues@max4mail.com" target="_blank">hugues@max4mail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF">
Hello joel<br>
<br>
you can test you post with curl<br>
<br>
curl -d "param1=value1¶m2=value2"
<a href="http://localhost:80/reminder" target="_blank">http://localhost:80/reminder</a><br>
<br>
<br>
add debug line in red<br>
<br>
<pre></pre>
<tt>sub send_out_mail {</tt><tt><br>
</tt><tt> use Email::Stuffer;</tt><div class=""><tt><br>
</tt><tt> my( $email, $body) = @_;</tt><tt><br>
</tt></div><tt> </tt><tt><font color="#ff0000"> debug $email, $body;</font></tt><div class=""><tt><br>
</tt><tt> my $sender = '<a href="mailto:joelz@pobox.com" target="_blank">joelz@pobox.com</a>';</tt><tt><br>
</tt><tt> Email::Stuffer->from($sender)</tt><tt><br>
</tt><tt> ->to($email)</tt><tt><br>
</tt><tt> ->subject("Reminder")</tt><tt><br>
</tt><tt> ->text_body($body)</tt><tt><br>
</tt><tt> ->send;</tt><tt><br>
</tt><tt><br>
</tt><tt>}</tt><tt><br>
</tt><br></div>
and change <br>
<br>
<tt>sub find_passwd {</tt><tt><br>
</tt><tt> return({ email => '<a href="mailto:toto@wanadoo.fr" target="_blank">toto@wanadoo.fr</a>', name =>
'Name', password => 'password', body => 'body' })</tt><tt><br>
</tt><tt> ;</tt><tt><br>
</tt><tt>}</tt><tt><br>
</tt><br>
<br>
<br>
the result seems correct ( without crash )<br>
<br>
<tt>[7255] core @0.000110> request: POST /reminder from
127.0.0.1 in /usr/local/share/perl5/Dancer/Handler.pm l. 56</tt><tt><br>
</tt><tt>[7255] core @0.000573> [hit #1]Trying to match 'POST
/reminder' against /^\/reminder$/ (generated from '/reminder') in
/usr/local/share/perl5/Dancer/Route.pm l. 84</tt><tt><br>
</tt><tt>[7255] core @0.000695> [hit #1] --> got 1 in
/usr/local/share/perl5/Dancer/Route.pm l. 102</tt><tt><br>
</tt><tt>[7255] core @0.001035> [hit #1]entering before hook in
/usr/local/share/perl5/Dancer/Hook.pm l. 58</tt><tt><br>
</tt><tt>[7255] debug @0.003781> [hit #1]toto@wanadoo.frbody in
/home/test/pobox/lib/<a href="http://pobox.pm" target="_blank">pobox.pm</a> l. 69</tt><tt><br>
</tt><tt>[7255] core @0.606941> [hit #1]response: 302 in
/usr/local/share/perl5/Dancer/Handler.pm l. 181</tt><tt><br>
</tt><br>
for my point of view, pb come from<br>
<pre>find_passwd { }</pre>
add debug ligne to check all, before send email,<br>
<br>
bye<br>
Hugues<br>
<br>
<div>Le 26/04/2014 09:09, Joel Roth a
écrit :<br>
</div><div><div class="h5">
<blockquote type="cite">
<pre>Hi Dancers,
During development, I've put a file with the
username/email/password on the site (generally bad practice,
I know), and have a button for sending a password reminder.
When the user posts a form with an "email" field to
the /reminder route (see below) it results in the following error,
which is issued *after* the mail is sent out:
The page '<a href="http://localhost:3000/reminder" target="_blank">http://localhost:3000/reminder</a>' couldn't be
loaded. Message Corrupt
I would expect a redirect to '/reminder-has-been-sent'
Do you have any suggestions?
Kind regards,
Joel
--
post '/reminder' => sub {
my $email = params->{email};
my $result = find_passwd($email);
session user => undef;
session failed_login => undef;
if ($result)
{
send_out_mail($result->{email}, $result->{body}); # sent!
redirect '/reminder-has-been-sent'; # no redirect
}
else
{
redirect '/email-not-found';
}
};
There is a "before" clause.
before sub {
if (!session('user') and request->path_info !~
m{(login|bye|reminder|reminder-has-been-sent|email-not-found)$}) {
# Pass the original path requested along to the handler:
session requested_path => request->path_info;
redirect('/login');
}
elsif ( ! authorized( session('user'), request->path_info)
and request->path_info ne '/forbidden'){
# Pass the original path requested along to the handler:
session requested_path => request->path_info;
redirect('/forbidden');
}
};
sub find_passwd {
my $user_or_email = shift;
# we expect to be in Dancer app directory
my @entries = read_file('pass');
my $body;
my ($name, $email, $username, $password);
map { chomp } @entries;
foreach my $entry( @entries ){
($name, $email, $username, $password) = split /\s*:\s*/, $entry;
next if $user_or_email ne $username and $user_or_email ne $email;
say "-->$name";
$body = mail_body($name, $username, $password);
last
}
return({ email => $email, name => $name, password => $password, body => $body })
if $body;
}
sub mail_body {
my ($name, $username, $password) = @_;
my ($first) = $name =~ /(.+?)\s*\S*$/;
#say $first;
<<FORM;
Dear $first,
This automated mail contains your login credentials for
<a href="http://example.com" target="_blank">http://example.com</a>
Your username is $username
Your password is $password
FORM
}
sub send_out_mail {
my( $email, $body) = @_;
my $sender = '<a href="mailto:joelz@pobox.com" target="_blank">joelz@pobox.com</a>';
Email::Stuffer->from($sender)
->to($email)
->subject("Reminder")
->text_body($body)
->send;
}
1
</pre>
</blockquote>
<br>
</div></div></div>
<br>_______________________________________________<br>
dancer-users mailing list<br>
<a href="mailto:dancer-users@dancer.pm">dancer-users@dancer.pm</a><br>
<a href="http://lists.preshweb.co.uk/mailman/listinfo/dancer-users" target="_blank">http://lists.preshweb.co.uk/mailman/listinfo/dancer-users</a><br>
<br></blockquote></div><br></div>