Skip to content

WireMail::quotedPrintableString() causes some email clients to display encoded FROM name as plain text #2183

@nurkka

Description

@nurkka

Short description of the issue

The WireMail core module builds the FROM header display name via:
WireMail::bundleEmailAndName() → WireMail::quotedPrintableString()
The method uses quoted_printable_encode() and wraps it as an RFC2047 encoded-word.

This can yield invalid encoded-words containing literal spaces (e.g. =?utf-8?Q?Firstname Lastname?=).
Some mail clients (confirmed in my case: eM Client) then display the raw encoded string in the sender field.

Steps to reproduce

$m = wireMail();
$m->to('recipient@example.com')
    ->from('sender@example.com', 'Firstname Lastname')
    ->subject('Test')
    ->body('Test')
    ->send();

Inspect raw headers:
FROM: may contain =?utf-8?Q?Firstname Lastname?=.

Expected

FROM header display name should be encoded so that it renders correctly in email clients (especially eM Client), which can only decode 100% valid RFC2047 (no spaces inside a single encoded-word).

Suggested fix

Replace quoted_printable_encode in WireMail::quotedPrintableString() with mb_encode_mimeheader() (mbstring):

public function quotedPrintableString($text) {  
    return mb_encode_mimeheader($text, 'UTF-8', 'Q', "\r\n");
}

This fix worked for me: eM Client now shows the FROM display name correctly.

File

wire/core/WireMail.php

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions