Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions Bugzilla/Mailer.pm
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ sub MessageToMTA {
$email->header_set('MIME-Version', '1.0')
if !$email->header('MIME-Version');

# We ensure there's a Message-ID header set otherwise some mailsystems
# treat us as spam.
$email->header_set('Message-ID', build_message_id())
if !$email->header('Message-ID');

# Encode the headers correctly in quoted-printable
foreach my $header ($email->header_names) {
$header = lc $header;
Expand Down Expand Up @@ -270,4 +275,23 @@ sub build_thread_marker {
return $threadingmarker;
}

# Builds Message-ID header
sub build_message_id {
my ($user_id) = @_;

if (!defined $user_id) {
$user_id = Bugzilla->user->id;
}

my $sitespec = '@' . Bugzilla->localconfig->urlbase;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, so the original patch on #146 already had it in params and you're changing it to localconfig? Yep, does seem that way. My diff was backwards when I made it apparently. In that case, I don't think this change is needed at all. urlbase is in params and not in localconfig, so the original patch in #146 was correct.

@kanru kanru Jun 21, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

grep Bugzilla->params->{'urlbase'} returned 0 matches but Bugzilla->localconfig->urlbase returned many matches though?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so it does... I didn't realize they moved that. Bugzilla/Config.pm has a shim to make sure the params reference still works though:

  $params{urlbase} = Bugzilla->localconfig->urlbase;

Probably to let old extensions still work.

That said, we should do this anyway.

$sitespec =~ s/:\/\//\./; # Make the protocol look like part of the domain
$sitespec =~ s/^([^:\/]+):(\d+)/$1/; # Remove a port number, to relocate
if ($2) {
$sitespec = "-$2$sitespec"; # Put the port number back in, before the '@'
}

my $rand_bits = generate_random_password(10);
my $message_id = "<bugzilla-$user_id-$rand_bits$sitespec>";
return $message_id;
}
1;