[Catalyst-commits] r9123 - in Catalyst-View-Email/0.10: . lib/Catalyst/View lib/Catalyst/View/Email

jshirley at dev.catalyst.perl.org jshirley at dev.catalyst.perl.org
Thu Jan 22 14:53:50 GMT 2009


Author: jshirley
Date: 2009-01-22 14:53:49 +0000 (Thu, 22 Jan 2009)
New Revision: 9123

Modified:
   Catalyst-View-Email/0.10/Changes
   Catalyst-View-Email/0.10/Makefile.PL
   Catalyst-View-Email/0.10/lib/Catalyst/View/Email.pm
   Catalyst-View-Email/0.10/lib/Catalyst/View/Email/Template.pm
Log:
Next version, handles falling back to plain text mails when Template is still in use, extra pod

Modified: Catalyst-View-Email/0.10/Changes
===================================================================
--- Catalyst-View-Email/0.10/Changes	2009-01-22 14:51:51 UTC (rev 9122)
+++ Catalyst-View-Email/0.10/Changes	2009-01-22 14:53:49 UTC (rev 9123)
@@ -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

Modified: Catalyst-View-Email/0.10/Makefile.PL
===================================================================
--- Catalyst-View-Email/0.10/Makefile.PL	2009-01-22 14:51:51 UTC (rev 9122)
+++ Catalyst-View-Email/0.10/Makefile.PL	2009-01-22 14:53:49 UTC (rev 9123)
@@ -8,7 +8,7 @@
 
 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 @@
     'MIME::Base64',
     'Authen::SASL';
 
-
 auto_install;
 WriteAll;

Modified: Catalyst-View-Email/0.10/lib/Catalyst/View/Email/Template.pm
===================================================================
--- Catalyst-View-Email/0.10/lib/Catalyst/View/Email/Template.pm	2009-01-22 14:51:51 UTC (rev 9122)
+++ Catalyst-View-Email/0.10/lib/Catalyst/View/Email/Template.pm	2009-01-22 14:53:49 UTC (rev 9123)
@@ -205,7 +205,7 @@
 =cut
 
 sub process {
-    my ( $self, $c ) = @_;
+    my ( $self, $c, @args ) = @_;
 
     # don't validate template_prefix
 
@@ -215,7 +215,8 @@
     
     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};
     

Modified: Catalyst-View-Email/0.10/lib/Catalyst/View/Email.pm
===================================================================
--- Catalyst-View-Email/0.10/lib/Catalyst/View/Email.pm	2009-01-22 14:51:51 UTC (rev 9122)
+++ Catalyst-View-Email/0.10/lib/Catalyst/View/Email.pm	2009-01-22 14:53:49 UTC (rev 9123)
@@ -6,12 +6,13 @@
 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 @@
     
     $ script/myapp_create.pl view Email Email
 
-In your app configuration (example in L<YAML>):
+In your app configuration:
 
-    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
+    __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 @@
             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 @@
 
 =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




More information about the Catalyst-commits mailing list