Improve error handling of malformed addresses

Created on 28 August 2020, almost 4 years ago
Updated 28 October 2023, 8 months ago

Problem/Motivation

D8.9.3
After updating SM from 1.0-beta1 to 2.0-beta2, it get an error when sending email via Simplenews module :

The website encountered an unexpected error. Please try again later.
Error: Call to undefined method Swift_Mime_Headers_UnstructuredHeader::getAddresses() in Drupal\swiftmailer\Utility\Conversion::swiftmailer_filter_message() (line 413 of modules/contrib/swiftmailer/src/Utility/Conversion.php).

Drupal\swiftmailer\Utility\Conversion::swiftmailer_filter_message(Object) (Line: 337)
Drupal\swiftmailer\Plugin\Mail\SwiftMailer->mail(Array) (Line: 50)
Drupal\mailsystem\Adapter->mail(Array) (Line: 307)
Drupal\Core\Mail\MailManager->doMail('simplenews', 'test', 'bpelvillain@gmail.com', 'fr', Array, '"=?UTF-8?B?Q29vcMOpcmF0aXZlcyBkJ0FjdGl2aXTDqXMgZXQgZCdFbXBsb2kgZW4gSWxsZS0=?=
=?UTF-8?B?ZXQtVmlsYWluZQ==?=" ', 1) (Line: 179)
Drupal\Core\Mail\MailManager->Drupal\Core\Mail\{closure}() (Line: 573)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 180)
Drupal\Core\Mail\MailManager->mail('simplenews', 'test', 'bpelvillain@gmail.com', 'fr', Array, '"=?UTF-8?B?Q29vcMOpcmF0aXZlcyBkJ0FjdGl2aXTDqXMgZXQgZCdFbXBsb2kgZW4gSWxsZS0=?=
=?UTF-8?B?ZXQtVmlsYWluZQ==?=" ', 1) (Line: 70)
Drupal\mailsystem\MailsystemManager->mail('simplenews', 'test', 'bpelvillain@gmail.com', 'fr', Array, '"=?UTF-8?B?Q29vcMOpcmF0aXZlcyBkJ0FjdGl2aXTDqXMgZXQgZCdFbXBsb2kgZW4gSWxsZS0=?=
=?UTF-8?B?ZXQtVmlsYWluZQ==?=" ') (Line: 332)
Drupal\simplenews\Mail\Mailer->sendMail(Object) (Line: 388)
Drupal\simplenews\Mail\Mailer->sendTest(Object, Array) (Line: 211)
Drupal\simplenews\Form\NodeTabForm->submitTestMail(Array, Object)
call_user_func_array(Array, Array) (Line: 114)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 52)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 593)
Drupal\Core\Form\FormBuilder->processForm('simplenews_node_tab', Array, Object) (Line: 321)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 91)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 573)
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: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
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: 708)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

This issue does'nt appear when testing via /admin/config/swiftmailer/test.

Steps to reproduce

  1. Install and configure Simplenews.
  2. Create a content from 'Newsletter issue' content type.
  3. From this content, click on Newsletter tab and send a test.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ“Œ Task
Status

Needs work

Version

2.0

Component

Code

Created by

πŸ‡«πŸ‡·France brulain

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.69.0 2024