BCC Functionality Broken in Drupal 8

Created on 15 August 2023, over 1 year ago

Problem/Motivation

Sending emails with BCC recipients does not work on Drupal 8. The issue is caused by this commit: https://git.drupalcode.org/project/smtp/-/commit/a46b2f8a0d0a8e9cfcbeb85...

An error was added in BCC handling for older Drupal versions. Instead of

<?php
            // @todo remove when dropping support for D8 and 9.2.
            if ($this->mimeTypeGuesser instanceof MimeTypeGuesserInterface) {
              // phpcs:ignore
              $mailer->AddBCC($bcc_comp['email'], (new UnstructuredHeader('BCC', $bcc_comp['name']))->getBodyAsString());
            }
            else {
              // @phpstan-ignore-next-line
               $mailer->FromName = Unicode::mimeHeaderEncode($from_name);
            }

It should be:

<?php
            // @todo remove when dropping support for D8 and 9.2.
            if ($this->mimeTypeGuesser instanceof MimeTypeGuesserInterface) {
              // phpcs:ignore
              $mailer->AddBCC($bcc_comp['email'], (new UnstructuredHeader('BCC', $bcc_comp['name']))->getBodyAsString());
            }
            else {
              // @phpstan-ignore-next-line
              $mailer->addBCC($bcc_comp['email'], $bcc_comp['name']);
            }

Steps to reproduce

Install module on Drupal 8.9.x and attempt to send an email with a BCC recipient.

Proposed resolution

Patch coming to make the code change.

πŸ› Bug report
Status

Needs review

Version

1.2

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States zengenuity

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

Comments & Activities

Production build 0.71.5 2024