SymfonyMailer RfcComplianceException when sending to multiple comma-separated addresses

Created on 9 May 2024, 12 months ago

Problem/Motivation

The SymfonyMailer class that was added in πŸ“Œ Add symfony/mailer into core RTBC does not properly handle multiple comma-separated email addresses in the $message['to'] variable that is produced by Drupal. It attempts to send the entire message['to'] string into the Symfony mailer to() method, which expects a single address. The addTo() method should be used to add additional addresses, or we can use to(...$toAddresses) with an array.

Reference: https://symfony.com/doc/current/mailer.html#email-addresses

Drupal core's MailManagerInterface::mail expects a

string $to</code parameter, so sending to multiple addresses requires formatting them as a comma-separated list (and that is the recommendation).

Reference: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Mail%21MailManagerInterface.php/function/MailManagerInterface%3A%3Amail/10

<h4 id="summary-steps-reproduce">Steps to reproduce</h4>

1. Enable the Symfony mailer per the instructions in this change record: https://www.drupal.org/node/3369935
2. Trigger an email to be sent to multiple comma-separated addresses.

<h3 id="summary-proposed-resolution">Proposed resolution</h3>

The <code>SymfonyMailer

class should parse $message['to'] into an array of addresses, and then use to(...$toAddresses) to pass them to Symfony mailer.

Remaining tasks

TBD

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

TBD.

πŸ› Bug report
Status

Active

Version

11.0 πŸ”₯

Component
MailΒ  β†’

Last updated 3 days ago

No maintainer
Created by

πŸ‡ΊπŸ‡ΈUnited States m.stenta

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024