Transform custom message headers with ucwords

Created on 14 July 2023, over 1 year ago

Problem/Motivation

Right now, all the custom headers are getting transformed to lowercase in SMTPMailSystem::mail() line 217:
$headers = array_change_key_case($message['headers']);

Totally makes sense to unify keys and apply checks.

In the end of switch/case, the default case adds the custom header as it is, but by that moment, the header is in lower case and the message client ignores it.
SMTPMailSystem::mail() line 478:
$mailer->AddCustomHeader($key . ': ' . $value);

E.g. if add 'In-Reply-To' in any hook_mail_alter(), the email client will receive it as 'in-reply-to' and will ignore it.
At least, the gmail ignores it.

Steps to reproduce

Add 'In-Reply-To' header in hook_mail_alter()

Proposed resolution

Unify the custom header with ucwords() and separator equal to '-'
$mailer->AddCustomHeader(ucwords($key, '-') . ': ' . $value);

The only header, so far, that does not follow the pattern Part1-Part2 is MessageID. Add case to set MessageID property if passed.

case 'messageid':
  $mailer->MessageID = $value;
  break;

Remaining tasks

-

User interface changes

-

API changes

-

Data model changes

-

πŸ› Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡¦Ukraine id.rem.dev

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

Comments & Activities

Production build 0.71.5 2024