Skip to content

fix(MailTransmission): Handle clients/servers picky about empty headers#12420

Open
joshtrichards wants to merge 1 commit intomainfrom
jtr/fix-mail-sending-empty-headers-exclusion
Open

fix(MailTransmission): Handle clients/servers picky about empty headers#12420
joshtrichards wants to merge 1 commit intomainfrom
jtr/fix-mail-sending-empty-headers-exclusion

Conversation

@joshtrichards
Copy link
Member

@joshtrichards joshtrichards commented Feb 13, 2026

Came up on the forum:

Changes:

  • New function buildHeaders to have same logic applied to sendMessage, saveDraft, saveLocalDraft
  • Set Cc and Bcc header on demand
  • Drop the detour through ModelMessage
  • Drop Date header (done by Horde Mime later)

@kesselb
Copy link
Contributor

kesselb commented Feb 13, 2026

Thanks a lot @joshtrichards for flagging it 👍

I've noticed that while working on #11043 #11889, and forgot to follow up 🙈
Indeed, we should not pass empty headers; that's just weird.

The CC/BCC headers are Horde_Mail_Rfc822_Address objects and do not evaluate to empty.
I'm going to push a fixup to address it.

@kesselb kesselb force-pushed the jtr/fix-mail-sending-empty-headers-exclusion branch from ff8e777 to 0753046 Compare February 13, 2026 18:59
@kesselb kesselb requested a review from GretaD as a code owner February 13, 2026 18:59
@kesselb kesselb requested review from DerDreschner, Copilot and hamza221 and removed request for kesselb February 13, 2026 19:00
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request fixes an issue where some email clients and servers reject messages containing empty Cc or Bcc headers. The fix refactors the header building logic to only include Cc and Bcc headers when they actually contain recipients.

Changes:

  • Introduced a new buildHeaders() method that conditionally adds Cc and Bcc headers only when they contain recipients
  • Removed the unnecessary detour through ModelMessage class
  • Removed the Date header from draft operations (handled automatically by Horde_Mime_Mail)

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
lib/Service/MailTransmission.php Added buildHeaders() method and refactored sendMessage(), saveLocalDraft(), and saveDraft() to use it; removed ModelMessage usage and Date header from drafts
tests/Unit/Service/MailTransmissionTest.php Added two new tests to verify Cc headers are included when present and omitted when empty

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@kesselb kesselb force-pushed the jtr/fix-mail-sending-empty-headers-exclusion branch from 0753046 to 0035ff9 Compare February 13, 2026 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants