It just occurred to me, that i forgot to tell you what it
does:
we now capture the mailer-method
all around more verbose error output now with suggestions
if warnings are enabled makes user aware of assumptions
- if not just run -X like you should damn well be doing
in production code.
much much more verbose checking on SMTP, we now check
the status of the send
On 8/30/07, Evan Carroll <lists evancarroll.com> wrote:
> In another attempt to eliminate obnoxious silent
assumptions and
> silent erroring, I present another patch. Enjoy.
>
> diff --git a/Email.pm b/Email.pm
> index 7fa09dc..5744a11 100644
> --- a/Email.pm
> +++ b/Email.pm
>  -1,6 +1,6 
> package Catalyst::View::Email;
>
> -use warnings;
> +use warnings::register;
> use strict;
>
> use Class::C3;
>  -13,7 +13,7  use base qw|Catalyst::View|;
>
> our $VERSION = '0.06';
>
> -__PACKAGE__->mk_accessors(qw(sender stash_key
content_type mailer));
> +__PACKAGE__->mk_accessors(qw(sender stash_key
content_type mailer
> mailer_method));
>
> =head1 NAME
>
>  -121,17 +121,42  sub new {
>
> my $mailer = Email::Send->new;
>
> - if ( my $method = $self->sender-> )
{
> - croak "$method is not supported, see
Email::Send"
> - unless
$mailer->mailer_available($method);
> - $mailer->mailer($method);
> - } else {
> - # Default case, run through the most likely
options first.
> - for ( qw/SMTP Sendmail Qmail/ ) {
> - $mailer->mailer($_) and last if
$mailer->mailer_available($_);
> + my $chosen_method; ## get the chosen_method;
> + if ( $chosen_method ||=
$self->sender-> ) {
> + croak "$chosen_method is not supported, see
Email::Send"
> + . "ntOther installed options might
include: [
> {[$mailer->all_mailers]} ]"
> + unless
$mailer->mailer_available($chosen_method);
> + }
> + else {
> +
> + foreach my $default_method ( qw/SMTP Sendmail
Qmail/ ) {
> +
> + if (
$mailer->mailer_available($default_method) ) {
> +
> + $chosen_method = $default_method;
> +
> + warnings::warnif( 'Warning: ' . __PACKAGE__
> + . " is making assumption that
$default_method is the
> desired method"
> + . "ntOther installed options might
include: [
> {[$mailer->all_mailers]} ]"
> + );
> +
> + last;
> +
> }
> +
> + }
> +
> + croak 'You have neither specified a valid ' .
__PACKAGE__ . ' method'
> + . ' nor could one be found in our suggested
list'
> + . "ntOther installed options might
include: [
> {[$mailer->all_mailers]} ]"
> + unless $chosen_method;
> +
> }
>
> + $mailer->mailer( $chosen_method );
> +
> + $self->mailer_method( $chosen_method );
> +
> if ( my $args = $self->sender->
) {
> if ( ref $args eq 'HASH' ) {
> $mailer->mailer_args([ %$args ]);
>  -190,7 +215,10  sub process {
> my $message = Email::MIME->create(%mime);
>
> if ( $message ) {
> - $self->mailer->send($message);
> + my $resp = $self->mailer->send($message);
> + croak "SMTP is dieing caught with
Email::Send::SMTP specific code $resp"
> + if $self->mailer_method eq 'SMTP' and
!$resp
> + ;
> } else {
> croak "Unable to create message";
> }
>
>
> --
> Evan Carroll
> System Lord of the Internets
> me evancarroll.com
> 832-445-8877
>
--
Evan Carroll
System Lord of the Internets
me evancarroll.com
832-445-8877
_______________________________________________
Catalyst-dev mailing list
Catalyst-dev lists.rawmode.org
http://lists.rawmode.org/mailman/listinfo/catalyst-dev
|