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->{method} ) { - 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->{method} ) { + croak "$chosen_method is not supported, see Email::Send" + . "\n\tOther 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" + . "\n\tOther 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' + . "\n\tOther installed options might include: [ @{[$mailer->all_mailers]} ]" + unless $chosen_method; + } + $mailer->mailer( $chosen_method ); + + $self->mailer_method( $chosen_method ); + if ( my $args = $self->sender->{mailer_args} ) { 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 [EMAIL PROTECTED] 832-445-8877 _______________________________________________ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/