[Catalyst] Catalyst::View::Email error handling problems
Hetényi Csaba
csabiwork at tata.hu
Fri Mar 17 09:56:24 GMT 2017
Dear Friends
Sorry for the beginner question!
I experiment with Catalyst::View::Email and i try to send mail to
multiple addresses in a while loop (from a database table, containing
email addresses: simply one row - one address):
> while ( my $userdata = $users_data->next ) {
>
> $c->stash->{email} = {
> to => $userdata->felhasznalo->emailaddr,
> from => '....',
> subject => '....',
> body => 'Body Body Body',
> };
>
> $c->forward( $c->view('Email') );
>
> if ( scalar( @{ $c->error } ) ) {
> #$c->error(0); # Reset the error condition if you need to
> $c->response->body('Oh noes!');
> } else {
> $c->response->body('Email sent A-OK! (At least as far as we
> can tell)');
> }
> }
Everything is working well, until changing an address to unexistent or
bad mail address intentionally.
At that point the $c->error checking not working, the while loop breaks
with the following response:
> |4.1.2 <sabidfgc at freeemail.hu>: Recipient address rejected: Domain not
> found ||||||Trace begun at
> /home/csabi/perl5/lib/perl5/Email/Sender/Transport/SMTPS.pm line 122|
...etc...
At the doc below:
http://search.cpan.org/~rjbs/Email-Sender-1.300030/lib/Email/Sender/Manual/QuickStart.pm
there is a section called: "in case of error"
in that:
> If you'd rather not have to catch exceptions for failure to send mail,
> you can use the|try_to_send|method, which can be imported
> as|try_to_sendmail|. This method will return just false on failure to
> send mail.
I'd like to try that way, but i do not know, how to implement in Catalyst.
If i use:
$c->forward( $c->view('Email') ) || return;
the while loop stops after the first run.
Thank You in advance!
Csabi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scsys.co.uk/pipermail/catalyst/attachments/20170317/a86007b3/attachment.htm>
More information about the Catalyst
mailing list