Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Mail_Mime breaks "Additional Message Headers" plugin #4966
Reported by Chumba on 8 Feb 2016 11:48 UTC as Trac ticket #1490657
The "Additional Message Headers" plugin included with Roundcube doesn't work any longer as intended due to a change in the Mail_Mime class.
At least in Roundcube 1.1.4, in the included Mail_Mime, the property (as it once was)
was changed to
Consequently, the message_headers() method of the Additional Message Headers plugin doesn't properly reset the message headers, i.e.
now refers to the wrong property; yet
wouldn't work either due to the property $headers now being protected.
As an improvement, it's possible to pass the $overwrite = true parameter to the headers() method, like this:
This allows to overwrite existing headers; but it still doesn't allow to unset previously set headers (like the X-Sender header), as nulled headers from the Additional Message Headers would simply be ignored.
Not sure how to 100% fix this issue. It is possible to hook message_outgoing_headers instead, and have full control over the headers before they are being sent to the Mail_Mime object, but according to the docs, this hook is depreciated?
Keywords: Additional Message Headers
Comment by @alecpl on 8 Feb 2016 16:09 UTC
Replying to Chumba:
I don't see why it wouldn't work. Or you mean it does not work with Mail_Mime < 1.9?
Comment by Chumba on 8 Feb 2016 16:58 UTC
Replying to alec:
I am using the Roundcube 1.1.4 "complete" package, which includes Mail_Mime (not sure what version, but I assume it is >= 1.9).
Before I was using Roundcube 1.0.1.
After I upgraded from 1.0.1 to 1.1.4, the "Additional Message Headers" plugin would no longer strip existing headers nor overwrite existing headers. It would only add new headers if configured to do so.
The reason is as explained in the post above. Additional Message Headers, even as shipped in Roundcube 1.1.4, assumes an older version of Mail_Mime (like the one distributed with Roundcube 1.0.1). It tries to empty the $_headers property, even though Mail_Mime doesn't use that property anymore (it is renamed to $headers). On top of that, it is no longer possible to overwrite the $headers property because it is protected and AFAIK Mail_Mime doesn't supply a setter to modify it directly.
Does this make more sense?
Feel free to give it a try. My config.inc.php for the plugin looks like this:
But neither the x-sender is removed from sending mail nor the message-id header replaced. The reason:
I was considering rewriting the plugin to make use of the message_outgoing_headers hook; but the depreciation notice made me hesitate.
Comment by Chumba on 9 Feb 2016 09:19 UTC
Thanks alec. Notice, this is only a partial fix as suggested in my comments above.
It won't allow Additional Message Headers to unset existing headers anymore (like in the example config how to remove x-sender).
Given that the Mail_Mime has protected the headers property and won't allow its direct setting or getting, perhaps it would be useful to reconsider the depreciation of message_outgoing_headers. At least unless there is another way how one can access and modify headers.