From ee2c1f16d6e24fa110939d0979e64f1a6f3db357 Mon Sep 17 00:00:00 2001 From: Dave Lawrence Date: Wed, 12 Sep 2012 00:23:27 -0400 Subject: Bug 789873 - RequestWhiner doesn't respect SecureMail settings for "Outstanding Requests" mail r=glob --- extensions/RequestWhiner/bin/whineatrequests.pl | 76 ++++++++++++------------- 1 file changed, 38 insertions(+), 38 deletions(-) (limited to 'extensions/RequestWhiner/bin/whineatrequests.pl') diff --git a/extensions/RequestWhiner/bin/whineatrequests.pl b/extensions/RequestWhiner/bin/whineatrequests.pl index b7ac8f029..f7cb61dbb 100755 --- a/extensions/RequestWhiner/bin/whineatrequests.pl +++ b/extensions/RequestWhiner/bin/whineatrequests.pl @@ -34,6 +34,8 @@ use lib qw(. lib); use Bugzilla; use Bugzilla::User; use Bugzilla::Mailer; +use Email::MIME; + use Bugzilla::Extension::RequestWhiner::Constants; my $dbh = Bugzilla->dbh; @@ -66,7 +68,7 @@ $sth_get_requests->execute(); # Build data structure my $requests = {}; - + while (my ($login_name, $flag_name, $attach_id, @@ -77,11 +79,11 @@ while (my ($login_name, if (!defined($requests->{$login_name})) { $requests->{$login_name} = {}; } - + if (!defined($requests->{$login_name}->{$flag_name})) { $requests->{$login_name}->{$flag_name} = []; } - + push(@{ $requests->{$login_name}->{$flag_name} }, { bug_id => $bug_id, attach_id => $attach_id, @@ -117,39 +119,37 @@ exit; sub mail { my $args = shift; my $addressee = $args->{recipient}; - - my $template = - Bugzilla->template_inner($addressee->settings->{'lang'}->{'value'}); - my $msg = ''; # it's a temporary variable to hold the template output - $args->{'alternatives'} ||= []; - - # Put together the different multipart MIME segments - $template->process("requestwhiner/mail.txt.tmpl", $args, \$msg) - or die($template->error()); - push @{$args->{'alternatives'}}, - { - 'content' => $msg, - 'type' => 'text/plain', - }; - $msg = ''; - - $template->process("requestwhiner/mail.html.tmpl", $args, \$msg) - or die($template->error()); - push @{$args->{'alternatives'}}, - { - 'content' => $msg, - 'type' => 'text/html', - }; - $msg = ''; - - # Now produce a ready-to-mail MIME-encoded message - $args->{'boundary'} = "----------" . $$ . "--" . time() . "-----"; - - $template->process("whine/multipart-mime.txt.tmpl", $args, \$msg) - or die($template->error()); - - MessageToMTA($msg); - - delete $args->{'boundary'}; - delete $args->{'alternatives'}; + my $template = Bugzilla->template; + my ($content, @parts); + + $template->process("requestwhiner/mail.txt.tmpl", $args, \$content) + || die($template->error()); + push(@parts, Email::MIME->create( + attributes => { + content_type => "text/plain", + }, + body => $content, + )); + + $content = ''; + $template->process("requestwhiner/mail.html.tmpl", $args, \$content) + || die($template->error()); + + push(@parts, Email::MIME->create( + attributes => { + content_type => "text/html", + }, + body => $content, + )); + + $content = ''; + $template->process("requestwhiner/header.txt.tmpl", $args, \$content) + || die($template->error()); + + # TT trims the trailing newline + my $email = new Email::MIME("$content\n"); + $email->content_type_set('multipart/alternative'); + $email->parts_set(\@parts); + + MessageToMTA($email); } -- cgit v1.2.3-24-g4f1b