Email name and address details issue when using Mimemail formatter for languages other than English

Created on 30 June 2023, about 1 year ago
Updated 9 October 2023, 9 months ago

Problem/Motivation

We are using Mimemail formatter in Drupal mailsystem settings. Using latest version of Mimemail โ†’ module.

Currently, both webform and mimemail modules are using the fix from https://www.drupal.org/node/3207439 โ†’ to remove deprecation. But this has started causing incorrect email name issue in mail headers when using Mimemail formatter in non-english languages.

Reason for this issue is, when using non-english language:

  • Webform module is updating the From header information from hook_mail by encoding the data in webform.module#L455
  • Later in code, Mimemail module is again trying to encode the already encoded From header data from its src/Plugin/Mail/MimeMail::format()
  • method in MimeMailFormatHelper.php#L115

This encoding of the already encoded data is causing render issue. Emails are not able to display correct From header info in non-english language.

Steps to reproduce

  1. Create a webform and add a email handler
  2. Override the Email handler's From header info with custom Name
  3. Translate the data in a different language e.g. Arabic
  4. Use mimemail and change Mail formatter to Mime Mail Mailer in Mail System settings
  5. Submit the webform and check the email From information in mailboxes (will attach an image which makes things understandable)

Proposed resolution

Currently there's no way to check if the address details is already encoded or not, (there is a method Symfony\Component\Mime\Header\MailboxHeader::tokenNeedsEncoding(), but its protected, so no use). So putting a condition in Mimemail module is not viable.

if thinking rationally, updating some data in hook_mail is generalised since all hook_mails are invoked together from different different modules, but the mail formatter's format() method gets invoked only once, whichever formatter selected in Mail System. So we can move this logic to Webform module's own formatter to avoid data clashing.

๐Ÿ› Bug report
Status

Fixed

Version

6.2

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia Supreetam09 Kolkata

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024