Drupal\Core\Entity\EntityStorageException: Email does not comply with addr-spec of RFC 2822.

Created on 9 July 2021, almost 3 years ago
Updated 12 October 2023, 9 months ago

Problem/Motivation

Some of our webforms have start failing on submit with error messages about the email "does not comply with addr-spec of RFC 2822".

After some investigation it appears to be happening when we are using a custom "Send From" name includes a comma. Example: "Smith, John"

Removing the comma in the from name resolves the issues and the webform submits fine. From our list of submissions the error appears to roughly coincide with our upgrade to version 6.0.4, but that could be coincidental.

The full error message is:

The website encountered an unexpected error. Please try again later.

Drupal\Core\Entity\EntityStorageException: Email ""Smith" does not comply with addr-spec of RFC 2822. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 810 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).
Symfony\Component\Mime\Address::create('"Smith') (Line: 125)
Symfony\Component\Mime\Address::createArray(Array) (Line: 84)
Symfony\Component\Mime\Header\Headers->addMailboxListHeader('From', Array, Array) (Line: 154)
Symfony\Component\Mime\Header\Headers->addHeader('From', Array) (Line: 92)
Drupal\Core\Mail\Plugin\Mail\PhpMail->mail(Array) (Line: 311)
Drupal\Core\Mail\MailManager->doMail('webform', 'REDACTED', 'example@example.com', 'en', Array, '"Smith, John" ', 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('webform', 'REDACTED', 'example@example.com', 'en', Array, '"Smith, John" ') (Line: 1164)
Drupal\webform\Plugin\WebformHandler\EmailWebformHandler->sendMessage(Object, Array) (Line: 856)
Drupal\webform\Plugin\WebformHandler\EmailWebformHandler->postSave(Object, , NULL) (Line: 2738)
Drupal\webform\Entity\Webform->invokeHandlers('postSave', Object, , NULL) (Line: 1209)
Drupal\webform\WebformSubmissionStorage->invokeWebformHandlers('postSave', Object, ) (Line: 1117)
Drupal\webform\WebformSubmissionStorage->doPostSave(Object, ) (Line: 455)
Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 801)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object) (Line: 980)
Drupal\webform\WebformSubmissionStorage->save(Object) (Line: 339)
Drupal\Core\Entity\EntityBase->save() (Line: 887)
Drupal\webform\Entity\WebformSubmission->save() (Line: 1887)
Drupal\webform\WebformSubmissionForm->save(Array, Object)
call_user_func_array(Array, Array) (Line: 113)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 51)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 593)
Drupal\Core\Form\FormBuilder->processForm('REDACTED', Array, Object) (Line: 321)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 48)
Drupal\Core\Entity\EntityFormBuilder->getForm(Object, 'test') (Line: 1230)
Drupal\webform\Entity\Webform->getSubmissionForm(Array, 'test') (Line: 128)
Drupal\webform\Controller\WebformTestController->testForm(Object)
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: 716)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

This error is similar to the one in: https://www.drupal.org/project/webform/issues/3219222 β†’ but we are not using a token value for the from email or name.

Steps to reproduce

  1. Create a webform that uses a email handler to send an email after a completed submission.
  2. Customize the "Send from" name to include a comma such as "Smith, John"
  3. Submitting the form should results in a WSOD with the above error message.
  4. Remove the comma from the "from name" such as "John Smith"
  5. Submitting the form should be successful
πŸ› Bug report
Status

Closed: outdated

Version

6.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States PCate

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