You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Base64-encoded message displayed without decoding when MIME-Version header is missing (Courier-IMAP 6.x) #10417
I can recreate the issue with all plugins disabled
Describe the issue
Description
I'm using Roundcube 1.7.5 (FreeBSD package 1.7.5,1) with Courier-IMAP 6.0.8.
I encountered an issue where Roundcube displays the Base64-encoded body of an email without decoding it when the message lacks the MIME-Version: 1.0 header.
The affected message contains the following headers:
Roundcube displays the decoded UTF-8 text even when the MIME-Version header is missing, as it did when using Courier-IMAP 5.3.2.
Actual behavior
Roundcube displays the raw Base64-encoded text when using Courier-IMAP 6.0.7 or 6.0.8.
Question
I understand that the message is not MIME-compliant because it lacks the required MIME-Version header.
However, would it be possible for Roundcube to handle such messages for backward compatibility, even when the IMAP server reports 7bit in BODYSTRUCTURE?
I've attached two sample messages that differ only in the presence or absence of the MIME-Version: 1.0 header.
I added debug logging to get_message() and confirmed that the fallback condition is false in both cases. I've attached the patch I used for debugging. rcupe_imap.php.patch
The fallback condition is false because $headers->ctype is text/plain in both cases.
The issue is not a mismatch in Content-Type, but a mismatch in Content-Transfer-Encoding between the message headers and the BODYSTRUCTURE returned by Courier-IMAP 6.x. The charset parameter is also missing from BODYSTRUCTURE when MIME-Version is absent.
Also, even if the outer condition were modified to allow text/plain, the elseif (preg_match('/^(text|application)\/(.*)/', ...)) branch would be taken, so rcube_mime::parse_message() would still not be called.
It appears that the existing fallback logic does not cover this case.
I can reproduce this from the BODYSTRUCTURE alone: get_message() already substitutes the Content-Type and charset from the message headers for single-part messages, but not the Content-Transfer-Encoding, so a '7bit' structure keeps the part from being decoded. I'll send a patch that takes the header's base64/quoted-printable encoding in that workaround.
I replaced rcube_imap.php in my local Roundcube 1.7.7 installation with the version from PR #10442 and confirmed that both with-MIME-Version.eml and without-MIME-Version.eml are now correctly decoded and displayed with Courier-IMAP 6.0.8.
This resolves the issue in my environment. Thank you for your help!
Thanks for testing the patch against Courier-IMAP 6.0.8 and for the detailed debug output, it made the cause easy to pin down. Good to know both files decode correctly now.
Activity
alecpl commentedon Nov 17, 2026
Yes, Roundcube depends on
BODYSTRUCTURE, unlike Thunderbird. However, there's a specialcase when we fallback to parsing the message.roundcubemail/program/lib/Roundcube/rcube_imap.php
Line 1963 in 9d38335
So, investigate why it still does not work. Maybe our parser/decoder can't handle such messages, or maybe this code path is not used.
tsnr commentedon Nov 18, 2026
Thanks for pointing me to the fallback logic.
I added debug logging to get_message() and confirmed that the fallback condition is false in both cases. I've attached the patch I used for debugging.
rcupe_imap.php.patch
with-MIME-Version.eml:
without-MIME-Version.eml:
The fallback condition is false because
$headers->ctypeistext/plainin both cases.The issue is not a mismatch in Content-Type, but a mismatch in Content-Transfer-Encoding between the message headers and the BODYSTRUCTURE returned by Courier-IMAP 6.x. The charset parameter is also missing from BODYSTRUCTURE when MIME-Version is absent.
Also, even if the outer condition were modified to allow
text/plain, theelseif (preg_match('/^(text|application)\/(.*)/', ...))branch would be taken, sorcube_mime::parse_message()would still not be called.It appears that the existing fallback logic does not cover this case.
MikeFTV commentedon Nov 25, 2026
I can reproduce this from the BODYSTRUCTURE alone: get_message() already substitutes the Content-Type and charset from the message headers for single-part messages, but not the Content-Transfer-Encoding, so a '7bit' structure keeps the part from being decoded. I'll send a patch that takes the header's base64/quoted-printable encoding in that workaround.
tsnr commentedon Nov 26, 2026
Thank you for the patch!
I replaced
rcube_imap.phpin my local Roundcube 1.7.7 installation with the version from PR #10442 and confirmed that bothwith-MIME-Version.emlandwithout-MIME-Version.emlare now correctly decoded and displayed with Courier-IMAP 6.0.8.This resolves the issue in my environment. Thank you for your help!
MikeFTV commentedon Nov 26, 2026
Thanks for testing the patch against Courier-IMAP 6.0.8 and for the detailed debug output, it made the cause easy to pin down. Good to know both files decode correctly now.
Fix decoding of base64/quoted-printable messages without MIME-Version…
Fix decoding of base64/quoted-printable messages without MIME-Version…
alecpl commentedon Nov 26, 2026
Fixed.