From 777c2a88de0994dbbb09fe1dd22a7544e7db21dc 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 Signed-off-by: Marcel de Rooy Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 54731a0ce10094b60fd0b9541c24fbffc49a2c05) Signed-off-by: Chris Cormack --- C4/Letters.pm | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/C4/Letters.pm b/C4/Letters.pm index 3de1aa3438..405dfed8a7 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="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; -- 2.39.5