Next version, handles falling back to plain text mails when Template is still in...
J. Shirley [Thu, 22 Jan 2009 14:53:49 +0000 (14:53 +0000)]
Changes
Makefile.PL
lib/Catalyst/View/Email.pm
lib/Catalyst/View/Email/Template.pm

diff --git a/Changes b/Changes
index 4edc849..dd7b575 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,15 @@
 Revision history for Perl extension Catalyst::View::Email.
 
+0.12    2009-01-22 06:52:00
+        - Fixing tests for new versions of MIME::Creator
+        - Better structure of the code so that ::Template can also handle
+          plain text views
+        - Added onto troubleshooting
+
+0.11    2008-07-04 09:14:00
+        - Fixing a bug where content-type was ignored so multipart/alternative
+          failed.  RT #32215
+
 0.10    2007-11-22 23:00:00
         - Refactored by Alexander Hartmaier with api changes
           and POD improvements
index 59d62ec..2ec4eb2 100644 (file)
@@ -8,7 +8,7 @@ requires 'Class::C3';
 
 requires 'Email::Send'          => '2.185';
 requires 'Email::MIME'          => '1.859';
-requires 'Email::MIME::Creator' => '1.453';
+requires 'Email::MIME::Creator' => '1.455';
 
 feature 'Template Toolkit Support',
     -default => 1,
@@ -23,6 +23,5 @@ feature 'Net::SMTP Support',
     'MIME::Base64',
     'Authen::SASL';
 
-
 auto_install;
 WriteAll;
index 9cd6d5a..471c882 100644 (file)
@@ -6,12 +6,13 @@ use strict;
 use Class::C3;
 use Carp;
 
+use Encode qw(encode decode);
 use Email::Send;
 use Email::MIME::Creator;
 
-use base qw/ Catalyst::View /;
+use parent 'Catalyst::View';
 
-our $VERSION = '0.11';
+our $VERSION = '0.12';
 
 __PACKAGE__->mk_accessors(qw/ mailer /);
 
@@ -32,34 +33,37 @@ Use the helper to create your View:
     
     $ script/myapp_create.pl view Email Email
 
-In your app configuration (example in L<YAML>):
-
-    View::Email:
-        # Where to look in the stash for the email information.
-        # 'email' is the default, so you don't have to specify it.
-        stash_key: email
-        # Define the defaults for the mail
-        default:
-            # Defines the default content type (mime type).
-            # mandatory
-            content_type: text/plain
-            # Defines the default charset for every MIME part with the content
-            # type text.
-            # According to RFC2049 a MIME part without a charset should
-            # be treated as US-ASCII by the mail client.
-            # If the charset is not set it won't be set for all MIME parts
-            # without an overridden one.
-            # Default: none
-            charset: utf-8
-        # Setup how to send the email
-        # all those options are passed directly to Email::Send
-        sender:
-            mailer: SMTP
-            # mailer_args is passed directly into Email::Send 
-            mailer_args:
-                Host:       smtp.example.com # defaults to localhost
-                username:   username
-                password:   password
+In your app configuration:
+
+    __PACKAGE__->config(
+        'View::Email' => {
+            # Where to look in the stash for the email information.
+            # 'email' is the default, so you don't have to specify it.
+            stash_key => 'email',
+            # Define the defaults for the mail
+            default => {
+                # Defines the default content type (mime type). Mandatory
+                content_type => 'text/plain',
+                # Defines the default charset for every MIME part with the 
+                # content type text.
+                # According to RFC2049 a MIME part without a charset should
+                # be treated as US-ASCII by the mail client.
+                # If the charset is not set it won't be set for all MIME parts
+                # without an overridden one.
+                # Default: none
+                charset => 'utf-8'
+            }
+            # Setup how to send the email
+            # all those options are passed directly to Email::Send
+            sender => {
+                mailer => 'SMTP'
+                # mailer_args is passed directly into Email::Send 
+                mailer_args => {
+                    Host     => 'smtp.example.com', # defaults to localhost
+                    username => 'username',
+                    password => 'password',
+            }
+    );
 
 =head1 NOTE ON SMTP
 
@@ -225,7 +229,7 @@ sub process {
             if $email->{bcc};
         push @$header, ('From' => delete $email->{from})
             if $email->{from};
-        push @$header, ('Subject' => delete $email->{subject})
+        push @$header, ('Subject' => Encode::encode('MIME-Header', delete $email->{subject}))
             if $email->{subject};
         push @$header, ('Content-type' => $email->{content_type})
             if $email->{content_type};
@@ -320,6 +324,24 @@ sub generate_message {
 
 =back
 
+=head1 TROUBLESHOOTING
+
+As with most things computer related, things break.  Email even more so.  
+Typically any errors are going to come from using SMTP as your sending method,
+which means that if you are having trouble the first place to look is at
+L<Email::Send::SMTP>.  This module is just a wrapper for L<Email::Send>,
+so if you get an error on sending, it is likely from there anyway.
+
+If you are using SMTP and have troubles sending, whether it is authentication
+or a very bland "Can't send" message, make sure that you have L<Net::SMTP> and,
+if applicable, L<Net::SMTP::SSL> installed.
+
+It is very simple to check that you can connect via L<Net::SMTP>, and if you
+do have sending errors the first thing to do is to write a simple script
+that attempts to connect.  If it works, it is probably something in your
+configuration so double check there.  If it doesn't, well, keep modifying
+the script and/or your mail server configuration until it does!
+
 =head1 SEE ALSO
 
 =head2 L<Catalyst::View::Email::Template> - Send fancy template emails with Cat
index 8559775..66d54e0 100644 (file)
@@ -205,7 +205,7 @@ L<Email::Send>.
 =cut
 
 sub process {
-    my ( $self, $c ) = @_;
+    my ( $self, $c, @args ) = @_;
 
     # don't validate template_prefix
 
@@ -215,7 +215,8 @@ sub process {
     
     my $stash_key = $self->{stash_key};
 
-    croak "No template specified for rendering"
+    # Go upstream if we don't have a template
+    $self->next::method($c, @args)
         unless $c->stash->{$stash_key}->{template}
             or $c->stash->{$stash_key}->{templates};