Add Drupal 10 support, fix fatal error when sending email

Created on 18 October 2021, about 3 years ago
Updated 8 March 2024, 10 months ago

Problem/Motivation

I was testing Monitoring with the sub module monitoring_mail. And when an email should be sent, I got the following errors:

Symfony\Component\Mime\Exception\RfcComplianceException: Email "<core_maintenance_mode.1634559166@web-ftorregrosa.docker.localhost>" does not comply with addr-spec of RFC 2822. in Symfony\Component\Mime\Address->__construct() (line 56 of /project/vendor/symfony/mime/Address.php).
Symfony\Component\Mime\Header\IdentificationHeader->setIds(Array) (Line: 61)
Symfony\Component\Mime\Header\IdentificationHeader->setId('') (Line: 34)
Symfony\Component\Mime\Header\IdentificationHeader->__construct('Message-ID', '') (Line: 104)
Symfony\Component\Mime\Header\Headers->addIdHeader('Message-ID', '', Array) (Line: 154)
Symfony\Component\Mime\Header\Headers->addHeader('Message-ID', '') (Line: 92)
Drupal\Core\Mail\Plugin\Mail\PhpMail->mail(Array) (Line: 311)
Drupal\Core\Mail\MailManager->doMail('monitoring_mail', 'sensor_notification', 'aaa@bbb.net', 'fr', Array, NULL, 1) (Line: 180)
Drupal\Core\Mail\MailManager->Drupal\Core\Mail\{closure}() (Line: 578)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 181)
Drupal\Core\Mail\MailManager->mail('monitoring_mail', 'sensor_notification', 'aaa@bbb.net', 'fr', Array) (Line: 113)
monitoring_mail_monitoring_run_sensors(Array)
call_user_func_array('monitoring_mail_monitoring_run_sensors', Array) (Line: 403)
Drupal\Core\Extension\ModuleHandler->invokeAll('monitoring_run_sensors', Array) (Line: 143)
Drupal\monitoring\SensorRunner->runSensors() (Line: 53)
Drupal\monitoring\Controller\SensorList->content()
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 578)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 158)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 717)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
require('/project/app/index.php') (Line: 4)

In monitoring_mail.module:

  $message['headers']['Message-ID'] = $message_id;
  // Set the header References, if there is a previous transition.
  if ($references = $storage->get($result->getSensorId())) {
    $message['headers']['References'] = $references;
  }

Both added headers provoke this error (that's why I wrote errors, because I tried by first commenting the Message-ID line).

Steps to reproduce

- enable monitoring and monitoring_email
- configure an email for notifications
- check Critical and advertisement as notification levels
- use the maintenance mode sensor to easily trigger a status change
- when an email should be sent, there is a fatal error.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Postponed: needs info

Version

1.0

Component

Code

Created by

🇫🇷France Grimreaper France 🇫🇷

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.

Production build 0.71.5 2024