[Catalyst-commits] r14441 - in Catalyst-View-Email/trunk: . lib/Catalyst/View lib/Catalyst/View/Email t

dhoss at dev.catalyst.perl.org dhoss at dev.catalyst.perl.org
Fri Mar 15 18:56:03 GMT 2013


Author: dhoss
Date: 2013-03-15 18:56:03 +0000 (Fri, 15 Mar 2013)
New Revision: 14441

Removed:
   Catalyst-View-Email/trunk/MANIFEST
   Catalyst-View-Email/trunk/README
Modified:
   Catalyst-View-Email/trunk/Makefile.PL
   Catalyst-View-Email/trunk/lib/Catalyst/View/Email.pm
   Catalyst-View-Email/trunk/lib/Catalyst/View/Email/Template.pm
   Catalyst-View-Email/trunk/t/05template.t
Log:
applied diff from github

Deleted: Catalyst-View-Email/trunk/MANIFEST
===================================================================
--- Catalyst-View-Email/trunk/MANIFEST	2013-03-15 17:15:04 UTC (rev 14440)
+++ Catalyst-View-Email/trunk/MANIFEST	2013-03-15 18:56:03 UTC (rev 14441)
@@ -1,38 +0,0 @@
-Changes
-inc/Module/AutoInstall.pm
-inc/Module/Install.pm
-inc/Module/Install/AutoInstall.pm
-inc/Module/Install/Base.pm
-inc/Module/Install/Can.pm
-inc/Module/Install/Fetch.pm
-inc/Module/Install/Include.pm
-inc/Module/Install/Makefile.pm
-inc/Module/Install/Metadata.pm
-inc/Module/Install/Win32.pm
-inc/Module/Install/WriteAll.pm
-lib/Catalyst/Helper/View/Email.pm
-lib/Catalyst/Helper/View/Email/Template.pm
-lib/Catalyst/View/Email.pm
-lib/Catalyst/View/Email/Template.pm
-Makefile.PL
-MANIFEST			This list of files
-META.yml
-README
-t/01use.t
-t/02pod.t
-t/04basic.t
-t/05template.t
-t/06config.t
-t/07mason.t
-t/lib/TestApp.pm
-t/lib/TestApp/Controller/Root.pm
-t/lib/TestApp/View/Email.pm
-t/lib/TestApp/View/Email/AppConfig.pm
-t/lib/TestApp/View/Email/Template.pm
-t/lib/TestApp/View/Email/Template/AppConfig.pm
-t/lib/TestApp/View/Mason.pm
-t/lib/TestApp/View/TT.pm
-t/root/text_html/test.m
-t/root/text_html/test.tt
-t/root/text_plain/test.m
-t/root/text_plain/test.tt

Modified: Catalyst-View-Email/trunk/Makefile.PL
===================================================================
--- Catalyst-View-Email/trunk/Makefile.PL	2013-03-15 17:15:04 UTC (rev 14440)
+++ Catalyst-View-Email/trunk/Makefile.PL	2013-03-15 18:56:03 UTC (rev 14441)
@@ -5,7 +5,7 @@
 all_from 'lib/Catalyst/View/Email.pm';
 author 'J. Shirley <jshirley at gmail.com>';
 license 'perl';
-
+version_from 'lib/Catalyst/View/Email.pm';
 test_requires 'Test::More';
 
 requires 'MIME::Base64'          => '3.08';

Modified: Catalyst-View-Email/trunk/lib/Catalyst/View/Email/Template.pm
===================================================================
--- Catalyst-View-Email/trunk/lib/Catalyst/View/Email/Template.pm	2013-03-15 17:15:04 UTC (rev 14440)
+++ Catalyst-View-Email/trunk/lib/Catalyst/View/Email/Template.pm	2013-03-15 18:56:03 UTC (rev 14441)
@@ -54,7 +54,6 @@
         $c->stash->{email} = {
             to          => 'jshirley at gmail.com',
             cc          => 'abraxxa at cpan.org',
-            bcc         => 'hidden at secret.com hidden2 at foobar.com',
             from        => 'no-reply at foobar.com',
             subject     => 'I am a Catalyst generated email',
             template    => 'test.tt',
@@ -275,9 +274,12 @@
 
     # single part api
     elsif ( $c->stash->{$stash_key}->{template} ) {
+        my $part_args = { template => $c->stash->{$stash_key}->{template} };
+        if (my $ctype = $c->stash->{$stash_key}->{content_type}) {
+            $part_args->{content_type} = $ctype;
+        }
         push @parts,
-          $self->generate_part( $c,
-            { template => $c->stash->{$stash_key}->{template}, } );
+          $self->generate_part( $c, $part_args );
     }
 
     delete $c->stash->{$stash_key}->{body};

Modified: Catalyst-View-Email/trunk/lib/Catalyst/View/Email.pm
===================================================================
--- Catalyst-View-Email/trunk/lib/Catalyst/View/Email.pm	2013-03-15 17:15:04 UTC (rev 14440)
+++ Catalyst-View-Email/trunk/lib/Catalyst/View/Email.pm	2013-03-15 18:56:03 UTC (rev 14441)
@@ -20,7 +20,7 @@
 
 has '_mailer_obj' => (
     is      => 'rw',
-    isa     => 'Email::Sender::Transport',
+    does    => 'Email::Sender::Transport',
     lazy    => 1,
     builder => '_build_mailer_obj',
 );
@@ -98,9 +98,9 @@
                 mailer => 'SMTP',
                 # mailer_args is passed directly into Email::Sender::Simple 
                 mailer_args => {
-                    Host     => 'smtp.example.com', # defaults to localhost
-                    username => 'username',
-                    password => 'password',
+                    host     => 'smtp.example.com', # defaults to localhost
+                    sasl_username => 'sasl_username',
+                    sasl_password => 'sasl_password',
             }
           }
         }
@@ -124,7 +124,6 @@
         $c->stash->{email} = {
             to      => 'jshirley at gmail.com',
             cc      => 'abraxxa at cpan.org',
-            bcc     => join ',', qw/hidden at secret.com hidden2 at foobar.com/,
             from    => 'no-reply at foobar.com',
             subject => 'I am a Catalyst generated email',
             body    => 'Body Body Body',
@@ -162,6 +161,32 @@
         ],
     };
 
+You can set the envelope sender and recipient as well:
+
+  $c->stash->{email} = {
+
+    envelope_from => 'envelope-from at example.com',
+    from          => 'header-from at example.com',
+
+    envelope_to   => [ 'foo at example.com', 'bar at example.com' ],
+    to            => 'Undisclosed Recipients:;',
+
+    ...
+  };
+
+You can set the envelope sender and recipient as well:
+
+  $c->stash->{email} = {
+
+    envelope_from => 'envelope-from at example.com',
+    from          => 'header-from at example.com',
+
+    envelope_to   => [ 'foo at example.com', 'bar at example.com' ],
+    to            => 'Undisclosed Recipients:;',
+
+    ...
+  };
+
 =head1 HANDLING ERRORS
 
 If the email fails to send, the view will die (throw an exception).
@@ -245,8 +270,6 @@
       if $email->{to};
     push @$header, ( 'Cc' => delete $email->{cc} )
       if $email->{cc};
-    push @$header, ( 'Bcc' => delete $email->{bcc} )
-      if $email->{bcc};
     push @$header, ( 'From' => delete $email->{from} )
       if $email->{from};
     push @$header,
@@ -283,7 +306,12 @@
     my $message = $self->generate_message( $c, \%mime );
 
     if ($message) {
-        my $return = sendmail( $message, { transport => $self->_mailer_obj } );
+        my $return = sendmail( $message,
+          {
+            exists $email->{envelope_from} ? ( from => $email->{envelope_from} ) : (),
+            exists $email->{envelope_to}   ? ( to   => $email->{envelope_to}   ) : (),
+            transport => $self->_mailer_obj,
+          } );
 
         # return is a Return::Value object, so this will stringify as the error
         # in the case of a failure.

Modified: Catalyst-View-Email/trunk/t/05template.t
===================================================================
--- Catalyst-View-Email/trunk/t/05template.t	2013-03-15 17:15:04 UTC (rev 14440)
+++ Catalyst-View-Email/trunk/t/05template.t	2013-03-15 18:56:03 UTC (rev 14441)
@@ -9,10 +9,11 @@
 use Email::Sender::Simple;
 use FindBin;
 use lib "$FindBin::Bin/lib";
-
+use Data::Dump qw(ddx);
 use_ok('Catalyst::Test', 'TestApp');
 
 my $response;
+my $response2;
 my $time = time;
 ok( ( $response = request("/template_email?time=$time"))->is_success,
     'request ok' );
@@ -31,5 +32,12 @@
 
 is($parts[1]->content_type, 'text/html', 'text/html ok');
 like($parts[1]->body, qr{<em>test-email\@example.com</em> on $time}, 'got content back');
-#like($emails[0]->body, qr/$time/, 'Got our email');
+
+ok( ( $response2 = request("/template_email_single?time=$time"))->is_success,
+    'request ok' );
+like( $response2->content, qr/Template Email Ok/, 'controller says ok' );
+my @emails2 = Email::Sender::Simple->default_transport->deliveries;
+my @parts2 = $emails2[0]->{'email'}[0]->parts;
+is($parts2[1]->content_type, 'text/html', 'text/html ok');
+like($parts2[1]->body, qr{<em>test-email\@example.com</em> on $time}, 'got content back');
 done_testing();




More information about the Catalyst-commits mailing list