iTop
iTop copied to clipboard
:bug: N°7917 SF#2272 EmailLaminas.php: Fix Message-ID format
Base information
Question | Answer |
---|---|
Related to a SourceForge thead / Another PR / Combodo ticket? | SourceForge ticket 2272 |
Type of change? | Bug fix |
Symptom
iTop since version 3.1 (after switching to Laminas-mail, N°4307) sends emails with incorrectly formatted Message-ID. This sometimes results in Gmail classifying them as spam or even outright refusing to accept them for delivery. In another case, a client was reporting issues with their (possibly custom) system for automated email processing. More information is in the above-linked SourceForge issue.
Reproduction procedure
- On iTop 3.1.1-1
- With PHP 7.4.33
- Make iTop send you an email (assuming Gmail inbox).
- If the email arrives at all, examine its message ID ("Show original" in Gmail web application).
- See that the message ID got changed to
<[email protected]>
and anX-Google-Original-Message-ID
header was added.
Cause
After switching to the Laminas-mail library, the addHeaderLine
function is used to add the Message-ID
header to the email that is about to be sent. This function can add arbitrary headers and uses Q-encoding to encode the entire value. This is not allowed for structured headers such as Message-ID
according to the relevant RFCs (RFC 2047, RFC 2822).
Proposed solution
Laminas-mail provides a MessageId
class. An object of this type is created and added using addHeader
.
Checklist before requesting a review
- [x] I have performed a self-review of my code
- [x] I have tested all changes I made on an iTop instance
- [ ] I have added a unit test, otherwise I have explained why I couldn't
- [x] Is the PR clear and detailed enough so anyone can understand digging in the code?