summaryrefslogtreecommitdiffstats
path: root/Bugzilla/BugMail.pm
diff options
context:
space:
mode:
authorByron Jones <bjones@mozilla.com>2011-07-25 16:16:26 +0200
committerByron Jones <bjones@mozilla.com>2011-07-25 16:16:26 +0200
commit037942d0b264bc6b11a67e1e3c84d6a215748558 (patch)
tree5dbb28c535e42453304e09db543b9675cb2143fb /Bugzilla/BugMail.pm
parent7ddff2f30647abe482a19a9fd38a44383c5b0242 (diff)
downloadbugzilla-037942d0b264bc6b11a67e1e3c84d6a215748558.tar.gz
bugzilla-037942d0b264bc6b11a67e1e3c84d6a215748558.tar.xz
Bug 589128: Adds a preference allowing users to choose between text or html
for bugmail. r=LpSolit, a=LpSolit
Diffstat (limited to 'Bugzilla/BugMail.pm')
-rw-r--r--Bugzilla/BugMail.pm24
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;
}