[Jifty-commit] r3648 - in jifty/branches/html-mail: lib/Jifty
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Tue Jul 10 15:37:47 EDT 2007
Author: ternus
Date: Tue Jul 10 15:37:41 2007
New Revision: 3648
Modified:
jifty/branches/html-mail/lib/Jifty/Notification.pm
jifty/branches/html-mail/t/TestApp/t/08-notifications.t
Log:
intermediate commit for HTML notification
Modified: jifty/branches/html-mail/lib/Jifty/Notification.pm
==============================================================================
--- jifty/branches/html-mail/lib/Jifty/Notification.pm (original)
+++ jifty/branches/html-mail/lib/Jifty/Notification.pm Tue Jul 10 15:37:41 2007
@@ -87,18 +87,31 @@
map { ( $_->can('email') ? $_->email : $_ ) } grep {$_} @recipients );
$self->log->debug("Sending a ".ref($self)." to $to");
return unless ($to);
-
+ my $message = "";
my $appname = Jifty->config->framework('ApplicationName');
-
- my $message = Email::MIME->create_html(
- header => [
- From => ($self->from || _('%1 <%2>' , $appname, Jifty->config->framework('AdminEmail'))) ,
- To => $to,
- Subject => Encode::encode('MIME-Header', $self->subject || _("A notification from %1!",$appname )),
- ],
- attributes => { charset => 'UTF-8' },
- body => $self->full_body
- );
+ if ($self->html_body) {
+ $message = Email::MIME->create_html(
+ header => [
+ From => ($self->from || _('%1 <%2>' , $appname, Jifty->config->framework('AdminEmail'))) ,
+ To => $to,
+ Subject => Encode::encode('MIME-Header', $self->subject || _("A notification from %1!",$appname )),
+ ],
+ attributes => { charset => 'UTF-8' },
+ text_body => $self->full_body,
+ body => $self->full_html
+ );
+ } else {
+ $message = Email::MIME->create(
+ header => [
+ From => ($self->from || _('%1 <%2>' , $appname, Jifty->config->framework('AdminEmail'))) ,
+ To => $to,
+ Subject => Encode::encode('MIME-Header', $self->subject || _("A notification from %1!",$appname )),
+ ],
+ attributes => { charset => 'UTF-8' },
+
+ body => $self->full_body
+ );
+ }
$message->encoding_set('8bit')
if (scalar $message->parts == 1);
$self->set_headers($message);
@@ -260,6 +273,17 @@
return join( "\n", grep { defined } $self->preface, $self->body, $self->footer );
}
+=head2 full_html
+
+Same as full_body, but with HTML.
+
+=cut
+
+sub full_html {
+ my $self = shift;
+ return join( "\n", grep { defined } $self->preface, $self->html_body, $self->footer );
+}
+
=head2 parts
The parts of the message. You want to override this if you want to
Modified: jifty/branches/html-mail/t/TestApp/t/08-notifications.t
==============================================================================
--- jifty/branches/html-mail/t/TestApp/t/08-notifications.t (original)
+++ jifty/branches/html-mail/t/TestApp/t/08-notifications.t Tue Jul 10 15:37:41 2007
@@ -5,11 +5,29 @@
use lib 't/lib';
use Jifty::SubTest;
-use Jifty::Test tests => 3;
+use Jifty::Test tests => 4;
+
use_ok('Jifty::Notification');
use_ok('Email::MIME::CreateHTML');
use_ok('Email::MIME');
+use_ok('Email::Send');
+
+my $html = "<html><body>This is the HTML portion of the test email</body></html>";
+
+my $text = "This is the text portion of the text email";
+
+my $test_email = Email::MIME->create_html(
+ header => [
+ From => 'test at test',
+ To => 'test2 at test2',
+ Subject => 'This is a test email',
+ ],
+ body => $html,
+ text_body => $text
+ );
+
+
-TODO: {local $TODO = "Actually write tests"; ok(0, "Test notifications")};
+# TODO: {local $TODO = "Actually write tests"; ok(0, "Test notifications")};
1;
More information about the Jifty-commit
mailing list