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

Issue fork monitoring-3244335

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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Grimreaper created an issue. See original summary.

ressa made their first commit to this issue’s fork.

ressa’s picture

Title: Fatal error when sending email » Add Drupal 10 support, fix fatal error when sending email

Thanks for reporting @Grimreaper, it looks like adding Symfony Mailer and Drupal 10 support allows email to be sent.

ressa’s picture

Status: Active » Needs review
Berdir’s picture

Status: Needs review » Needs work

This should not depend on symfony mailer. I'm not sure why the message ID is being set as an empty string, it shouldn't do that.

Berdir’s picture

Status: Needs work » Postponed (maintainer needs more info)

Drupal 10 support was fixed in #3426553: Use Gitlab CI and fix tests unclear to me what the problem here is.