make it die more.
Marcus Ramberg [Wed, 22 Mar 2006 09:43:26 +0000 (09:43 +0000)]
Changes
Email.pm

diff --git a/Changes b/Changes
index 87ccd00..8009c73 100644 (file)
--- a/Changes
+++ b/Changes
@@ -3,6 +3,7 @@ Revision history for Perl extension Catalyst::Plugin::Email.
 0.06
         - Added more extensive docs on config and usage.
           (Carl Franks)
+       - Make it croak if recipient is empty.
 
 0.05  Thu Nov 17 22:00:00 2005
         - Added docs on sending email using a TT template.
index 15c0e45..7945e66 100644 (file)
--- a/Email.pm
+++ b/Email.pm
@@ -4,6 +4,7 @@ use strict;
 use Email::Send;
 use Email::MIME;
 use Email::MIME::Creator;
+use Carp qw/croak/;
 
 our $VERSION = '0.06';
 
@@ -101,6 +102,8 @@ arrayref of Email::MIME objects.
 sub email {
     my $c = shift;
     my $email = $_[1] ? {@_} : $_[0];
+    croak "Can't send mail without recipient"
+       unless length($email->{To});
     $email = Email::MIME->create(%$email);
     my $args = $c->config->{email} || [];
     my @args = @{$args};