From b67f8f8fb37b25866d3ffa671d4a24d50d03df8a Mon Sep 17 00:00:00 2001 From: David Cook Date: Tue, 23 Dec 2014 14:13:39 +1100 Subject: [PATCH] Bug 12739 - SendAlerts function does not take care of "html" format or UTF-8 Pt. 2 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 --- C4/Letters.pm | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/C4/Letters.pm b/C4/Letters.pm index a11c862..405dfed 100644 --- a/C4/Letters.pm +++ b/C4/Letters.pm @@ -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="utf8"', - + 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="utf8"', + 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="utf8"' + 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; -- 1.7.10.4