diff options
Diffstat (limited to 'Bugzilla/BugMail.pm')
-rw-r--r-- | Bugzilla/BugMail.pm | 24 |
1 files changed, 15 insertions, 9 deletions
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; } |