From 037942d0b264bc6b11a67e1e3c84d6a215748558 Mon Sep 17 00:00:00 2001 From: Byron Jones Date: Mon, 25 Jul 2011 22:16:26 +0800 Subject: Bug 589128: Adds a preference allowing users to choose between text or html for bugmail. r=LpSolit, a=LpSolit --- Bugzilla/BugMail.pm | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'Bugzilla/BugMail.pm') diff --git a/Bugzilla/BugMail.pm b/Bugzilla/BugMail.pm index 03eb1925d..55eeeab25 100644 --- a/Bugzilla/BugMail.pm +++ b/Bugzilla/BugMail.pm @@ -374,35 +374,41 @@ sub sendMail { sub _generate_bugmail { my ($user, $vars) = @_; - my $template = Bugzilla->template_inner($user->settings->{'lang'}->{'value'}); + my $template = Bugzilla->template_inner($user->setting('lang')); my ($msg_text, $msg_html, $msg_header); $template->process("email/bugmail-header.txt.tmpl", $vars, \$msg_header) || ThrowTemplateError($template->error()); $template->process("email/bugmail.txt.tmpl", $vars, \$msg_text) || ThrowTemplateError($template->error()); - $template->process("email/bugmail.html.tmpl", $vars, \$msg_html) - || ThrowTemplateError($template->error()); - + my @parts = ( Email::MIME->create( attributes => { content_type => "text/plain", }, body => $msg_text, - ), - Email::MIME->create( + ) + ); + if ($user->setting('email_format') eq 'html') { + $template->process("email/bugmail.html.tmpl", $vars, \$msg_html) + || ThrowTemplateError($template->error()); + push @parts, Email::MIME->create( attributes => { content_type => "text/html", }, body => $msg_html, - ), - ); + ); + } # TT trims the trailing newline, and threadingmarker may be ignored. my $email = new Email::MIME("$msg_header\n"); + if (scalar(@parts) == 1) { + $email->content_type_set($parts[0]->content_type); + } else { + $email->content_type_set('multipart/alternative'); + } $email->parts_set(\@parts); - $email->content_type_set('multipart/alternative'); return $email; } -- cgit v1.2.3-24-g4f1b