Problem/Motivation

In a new project I'm working on I get several error messages when sending an email:
Warning: Undefined array key "Content-Type" in Drupal\mimemail\Plugin\Mail\MimeMail->format() (line 91 of
modules/contrib/mimemail/src/Plugin/Mail/MimeMail.php).

Deprecated function: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in Drupal\mimemail\Plugin\Mail\MimeMail->format() (line 91 of modules/contrib/mimemail/src/Plugin/Mail/MimeMail.php).

In my case it's because the variable $message['headers']['Content-Type'] can be empty.

Proposed resolution

Check if the variable exists and add $matches to the preg_match function.

CommentFileSizeAuthor
#3 3481180-2.patch1.2 KBcmarrufo

Issue fork mimemail-3481180

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

cmarrufo created an issue. See original summary.

mohd sahzad made their first commit to this issue’s fork.

cmarrufo’s picture

StatusFileSize
new1.2 KB

Attached patch.

cmarrufo’s picture

Status: Active » Needs review

  • mark_fullmer committed ecc490e2 on 2.0.x
    [#3481180] bug: Warning: Undefined array key Content-Type in Drupal\...
mark_fullmer’s picture

Status: Needs review » Fixed

Thanks. This is a no-nonsense check for an edge case, so I have no problem adding this conditional. Merged -- will be included in the next release!

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.