Skip to content

Bug 1837680: Add Message-ID header when missing at send#146

Merged
justdave merged 9 commits into
bugzilla:mainfrom
mrenvoize:bug_1837680
Jul 11, 2026
Merged

Bug 1837680: Add Message-ID header when missing at send#146
justdave merged 9 commits into
bugzilla:mainfrom
mrenvoize:bug_1837680

Conversation

@mrenvoize

Copy link
Copy Markdown
Contributor

Detect whether a Message-ID header has been included in the message passed to MessageToMTA and generate one if it's missing.

GMail and other modern mail services now expect a Message-ID as part of the message else they mark them as spam or drop them entirely.

** This is a port of the same bug fix submitted for Bugzilla 5.2 **

@justdave

justdave commented Jun 6, 2026

Copy link
Copy Markdown
Member

GitHub isn't very good with messaging... the force-push was rebasing this PR on top of the target branch since there's been a bunch of upstream changes since it was filed.

@justdave justdave left a comment

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.

The review comments from bugzilla/bugzilla#205 also apply here.

@mrenvoize

mrenvoize commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

Rebased, fixes for comments applied and unit test added.

@mrenvoize mrenvoize force-pushed the bug_1837680 branch 3 times, most recently from 1f79550 to 29db591 Compare June 23, 2026 07:11
@mrenvoize

Copy link
Copy Markdown
Contributor Author

I've lost track.. is there anything outstanding here?

@justdave justdave left a comment

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.

I've lost track.. is there anything outstanding here?

I just added some review comments on the 5.2 PR which probably apply here as well.

mrenvoize and others added 6 commits July 10, 2026 15:58
Detect whether a Message-ID header has been included in the message
passed to MessageToMTA and generate one if it's missing.

GMail and other modern mail services now expect a Message-ID as part of
the message else they mark them as spam or drop them entirely.
Bugzilla->params->{'urlbase'} has been moved to Bugzilla->localconfig->urlbase

Signed-off-by: Kan-Ru Chen <kanru@kanru.info>
- Strip path components from urlbase when building sitespec, as '/' is
  illegal after '@' in a Message-ID (affects both build_thread_marker
  and build_message_id)
- Fix stale $2 capture variable risk by conditioning port relocation on
  the substitution succeeding, in both functions
- Avoid falling back to Bugzilla->user->id in build_message_id, which
  is called from contexts with no logged-in user; random bits ensure
  uniqueness without a user identifier
- Remove trailing whitespace from the spam-guard comment and blank line
- Omit the user_id segment entirely when absent rather than producing
  a double-dash (bugzilla--rand@domain), giving bugzilla-rand@domain
Test the sitespec transformation for four urlbase forms (plain, with
path, with port, with port+path) to guard against regressions in the
'/' stripping and port relocation logic. Also covers user_id handling
in build_message_id (present, absent, no double-dash).
Stripping the path from urlbase loses information: two independent
Bugzilla installs hosted in different subdirectories of the same
domain (e.g. /team-a/ and /team-b/) would produce identical sitespecs,
letting mail clients that group by References/In-Reply-To/Message-ID
cross-thread unrelated bugs from separate installations.

Relocate the path in front of the domain instead, the same way the
port number is already relocated, sanitizing any internal '/' since
it's illegal in a domain. Updates build_thread_marker and
build_message_id identically, plus the corresponding tests.
@mrenvoize

Copy link
Copy Markdown
Contributor Author

Follow-up Pushed

@mrenvoize mrenvoize requested a review from justdave July 10, 2026 15:21

@justdave justdave left a comment

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.

Fixes look good. I wasn't expecting subdir and port to end up on the front side of the @ but that's legal and works for me. :-)

Comment thread t/014mailer.t Outdated
@justdave justdave self-requested a review July 11, 2026 05:56

@justdave justdave left a comment

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.

Looks good with that cleared up.

@justdave justdave merged commit adfd70a into bugzilla:main Jul 11, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants