From fedc614940493768c53791939065fcf72ac5414b Mon Sep 17 00:00:00 2001 From: Byron Jones Date: Mon, 31 Aug 2015 12:20:49 +0800 Subject: Bug 714724 - correctly encode emails as quoted-printable r=LpSolit,a=sgreen --- whine.pl | 52 ++++++++++------------------------------------------ 1 file changed, 10 insertions(+), 42 deletions(-) (limited to 'whine.pl') diff --git a/whine.pl b/whine.pl index a7e3ee1cf..dfc405200 100755 --- a/whine.pl +++ b/whine.pl @@ -21,6 +21,7 @@ use Bugzilla::Constants; use Bugzilla::Search; use Bugzilla::User; use Bugzilla::Mailer; +use Bugzilla::MIME; use Bugzilla::Util; use Bugzilla::Group; @@ -346,53 +347,20 @@ while (my $event = get_next_event) { # - subject Subject line for the message # - recipient user object for the recipient # - author user object of the person who created the whine event -# -# In addition, mail adds two more fields to $args: -# - alternatives array of hashes defining mime multipart types and contents -# - boundary a MIME boundary generated using the process id and time -# sub mail { my $args = shift; - my $addressee = $args->{recipient}; # Don't send mail to someone whose bugmail notification is disabled. - return if $addressee->email_disabled; - - my $template = Bugzilla->template_inner($addressee->setting('lang')); - my $msg = ''; # it's a temporary variable to hold the template output - $args->{'alternatives'} ||= []; - - # put together the different multipart mime segments + return if $args->{recipient}->email_disabled; - $template->process("whine/mail.txt.tmpl", $args, \$msg) - or die($template->error()); - push @{$args->{'alternatives'}}, + $args->{to_user} = $args->{recipient}; + MessageToMTA(generate_email( + $args, { - 'content' => $msg, - 'type' => 'text/plain', - }; - $msg = ''; - - $template->process("whine/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'}; - + header => 'whine/header.txt.tmpl', + text => 'whine/mail.txt.tmpl', + html => 'whine/mail.html.tmpl', + } + )); } # run_queries runs all of the queries associated with a schedule ID, adding -- cgit v1.2.3-24-g4f1b