Bug 12739 - SendAlerts function does not take care of "html" format or UTF-8 Pt. 2
authorDavid Cook <dcook@prosentient.com.au>
Tue, 23 Dec 2014 03:13:39 +0000 (14:13 +1100)
committerTomas Cohen Arazi <tomascohen@gmail.com>
Mon, 30 Mar 2015 16:36:44 +0000 (13:36 -0300)
The emails sent via SendAlerts don't take into account HTML format.

_TEST PLAN_

Before applying:

1) Change system preference "AutoEmailOpacUser" to "Send"
2) Change "ACCTDETAILS" notice to HTML and add HTML to it
3) Create a new user with your email address
4) Note how the email displays the HTML tags as plain text

Apply patch

5) Create a new user with your email address
6) Note how the email displays the email as an HTML email

For thoroughness:

7) Change "ACCTDETAILS" notice to non-HTML
8) Create a new user with your email address
9) Note how the email displays the HTML as plain text

Signed-off-by: Paola Rossi <paola.rossi@cineca.it>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>

C4/Letters.pm

index 3de1aa3..405dfed 100644 (file)
@@ -430,10 +430,8 @@ sub SendAlerts {
                     replyto => $branchdetails->{'branchreplyto'},
                     sender  => $branchdetails->{'branchreturnpath'},
                     subject => Encode::encode( "utf8", "" . $letter->{title} ),
-                    message =>
-                      Encode::encode( "utf8", "" . $letter->{content} ),
-                    contenttype => 'text/plain; charset="utf-8"',
-
+                    message => $letter->{'is_html'} ? _wrap_html( Encode::encode( "utf8", $letter->{'content'} ), Encode::encode( "utf8", "" . $letter->{'title'}  ) ) : Encode::encode( "utf8", "" . $letter->{'content'} ),
+                    contenttype => $letter->{'is_html'} ? 'text/html; charset="utf-8"' : 'text/plain; charset="utf-8"',
                 }
             );
             sendmail(%mail) or carp $Mail::Sendmail::error;
@@ -518,8 +516,8 @@ sub SendAlerts {
             Cc             => join( ',', @cc),
             From           => $userenv->{emailaddress},
             Subject        => Encode::encode( "utf8", "" . $letter->{title} ),
-            Message        => Encode::encode( "utf8", "" . $letter->{content} ),
-            'Content-Type' => 'text/plain; charset="utf-8"',
+            Message => $letter->{'is_html'} ? _wrap_html( Encode::encode( "utf8", $letter->{'content'} ), Encode::encode( "utf8", "" . $letter->{'title'}  ) ) : Encode::encode( "utf8", "" . $letter->{'content'} ),
+            'Content-Type' => $letter->{'is_html'} ? 'text/html; charset="utf-8"' : 'text/plain; charset="utf-8"',
         );
 
         $mail{'Reply-to'} = C4::Context->preference('ReplytoDefault')
@@ -567,8 +565,8 @@ sub SendAlerts {
                 replyto => $branchdetails->{'branchreplyto'},
                 sender  => $branchdetails->{'branchreturnpath'},
                 subject => Encode::encode( "utf8", "" . $letter->{'title'} ),
-                message => Encode::encode( "utf8", "" . $letter->{'content'} ),
-                contenttype => 'text/plain; charset="utf-8"'
+                message => $letter->{'is_html'} ? _wrap_html( Encode::encode( "utf8", $letter->{'content'} ), Encode::encode( "utf8", "" . $letter->{'title'}  ) ) : Encode::encode( "utf8", "" . $letter->{'content'} ),
+                contenttype => $letter->{'is_html'} ? 'text/html; charset="utf-8"' : 'text/plain; charset="utf-8"',
             }
         );
         sendmail(%mail) or carp $Mail::Sendmail::error;