Call to undefined method Symfony\Component\Mime\Header\Headers::addHeader()

Created on 15 January 2022, almost 3 years ago
Updated 16 May 2023, over 1 year ago

After upgrading to Drupal 9.3 I'm getting errors with mail system. I can't say for sure this started in 9.3 because I disabled mail functions for a time while testing other parts of my system.

Error: Call to undefined method Symfony\Component\Mime\Header\Headers::addHeader() in Drupal\Core\Mail\Plugin\Mail\PhpMail->mail() (line 92 of [root]/core/lib/Drupal/Core/Mail/Plugin/Mail/PhpMail.php)

Any ideas on this?

πŸ’¬ Support request
Status

Closed: works as designed

Version

9.3

Component
MailΒ  β†’

Last updated 21 days ago

No maintainer
Created by

πŸ‡ΊπŸ‡ΈUnited States dmudie

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Hi,

    I'm having the same problem, but only when i'm logged in Drupal via SimpleSAML. I installed everything via composer. Did you find solution for this @La558 ? Thx.

    Regards.

  • πŸ‡¬πŸ‡§United Kingdom davej

    Found another way this error can occur, on a D9 / CiviCRM site with the Omnipay CiviCRM extension, which includes an older copy of the Symfony mime library. Details at symfony conflicts with D9.

  • Hey @davej,

    You wrote: "The version of mime in the extension (4.4.0) lacks the addHeader() method in Headers.php, however it's present in the D9 version of mime (5.2.0 in this case)." in that post, but i don't understand which extension you talk about - webforms? I can not find "mime" extension in D9 so how do you upgrade mime to higher version? Thx.

    Regards.

  • This is really strange. So, the mime version i'm using in vendor/symfony/mime/ is 5.2 and in file:

    vendor/symfony/mime/Header/Headers.php

    there is a function called addHeader but i still get this error. What is going on here??

  • πŸ‡¬πŸ‡§United Kingdom davej

    Hi @orcalator, most likely there are multiple copies of the Mime library and the code is picking up an older one that doesn't have the addHeader() method. #16 had this issue with Simplesamlphp.

Production build 0.71.5 2024