By alexpott on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
9.2.x
Introduced in version:
9.2.0
Issue links:
Description:
Drupal's mime header encoding didn't correctly follow RFC 2047.
Over the years other solutions have emerged that handle this better, including some of PHP's built-in features.
As a result the Drupal\Component\Utility\Mail class and its ::formatDisplayName method have been deprecated as follows
Before
$headers['From'] = Mail::formatDisplayName('foo@example.com');
After
use Symfony\Component\Mime\Address;
use Symfony\Component\Mime\Header\MailboxHeader;
$mailbox = new MailboxHeader('From', new Address('foo@example.com'));
$headers['From'] = $mailbox->getBodyAsString();
Before
$mail_subject = Unicode::mimeHeaderEncode($message['subject']);
After
use Symfony\Component\Mime\Header\UnstructuredHeader;
$mail_subject = (new UnstructuredHeader('subject', $message['subject']))->getBodyAsString();
Before
$decoded_string = Unicode::mimeHeaderDecode($encoded_string)
After
$decoded_string = iconv_mime_decode($encoded_string)
Impacts:
Module developers