@@ -379,7 +379,14 @@ sub sendMail {
379379 if (Bugzilla-> params-> {' use_mailer_queue' }) {
380380 enqueue($vars );
381381 } else {
382- MessageToMTA(_generate_bugmail($vars ));
382+ MessageToMTA(generate_email(
383+ $vars ,
384+ {
385+ header => ' email/bugmail-header.txt.tmpl' ,
386+ text => ' email/bugmail.txt.tmpl' ,
387+ html => ' email/bugmail.html.tmpl'
388+ }
389+ ));
383390 }
384391
385392 return 1;
@@ -419,7 +426,14 @@ sub dequeue {
419426 }
420427 }
421428 # generate bugmail and send
422- MessageToMTA(_generate_bugmail($vars ), 1);
429+ MessageToMTA(generate_email(
430+ $vars ,
431+ {
432+ header => ' email/bugmail-header.txt.tmpl' ,
433+ text => ' email/bugmail.txt.tmpl' ,
434+ html => ' email/bugmail.html.tmpl'
435+ }
436+ ), 1);
423437}
424438
425439sub _flatten_object {
@@ -432,56 +446,6 @@ sub _flatten_object {
432446 return $cache -> {$key } ||= $object -> flatten_to_hash;
433447}
434448
435- sub _generate_bugmail {
436- my ($vars ) = @_ ;
437- my $user = $vars -> {to_user };
438- my $template = Bugzilla-> template_inner($user -> setting(' lang' ));
439- my ($msg_text , $msg_html , $msg_header );
440- state $use_utf8 = Bugzilla-> params-> {' utf8' };
441-
442- $template -> process(" email/bugmail-header.txt.tmpl" , $vars , \$msg_header )
443- || ThrowTemplateError($template -> error());
444- $template -> process(" email/bugmail.txt.tmpl" , $vars , \$msg_text )
445- || ThrowTemplateError($template -> error());
446-
447- my @parts = (
448- Bugzilla::MIME-> create(
449- attributes => {
450- content_type => ' text/plain' ,
451- charset => $use_utf8 ? ' UTF-8' : ' iso-8859-1' ,
452- encoding => ' quoted-printable' ,
453- },
454- body_str => $msg_text ,
455- encode_check => Encode::FB_DEFAULT
456- )
457- );
458- if ($user -> setting(' email_format' ) eq ' html' ) {
459- $template -> process(" email/bugmail.html.tmpl" , $vars , \$msg_html )
460- || ThrowTemplateError($template -> error());
461- push @parts , Bugzilla::MIME-> create(
462- attributes => {
463- content_type => ' text/html' ,
464- charset => $use_utf8 ? ' UTF-8' : ' iso-8859-1' ,
465- encoding => ' quoted-printable' ,
466- },
467- body_str => $msg_html ,
468- encode_check => Encode::FB_DEFAULT
469- );
470- }
471-
472- my $email = Bugzilla::MIME-> new($msg_header );
473-
474- # If there's only one part, we don't need to set the overall content type
475- # because Email::MIME will automatically take it from that part (bug 1657496)
476- if (scalar (@parts ) > 1) {
477- $email -> content_type_set(' multipart/alternative' );
478- # Some mail clients need same encoding for each part, even empty ones.
479- $email -> charset_set(' UTF-8' ) if $use_utf8 ;
480- }
481- $email -> parts_set(\@parts );
482- return $email ;
483- }
484-
485449sub _get_diffs {
486450 my ($bug , $end , $user_cache ) = @_ ;
487451 my $dbh = Bugzilla-> dbh;
0 commit comments