Problem/Motivation
When sending a mail without a mailer transport configured, this results in the following error:
The website encountered an unexpected error. Please try again later.
Drupal\Core\Entity\EntityStorageException: The "" mailer DSN must contain a scheme. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 810 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).
Symfony\Component\Mailer\Transport->parseDsn() (Line: 113)
Symfony\Component\Mailer\Transport->fromString() (Line: 74)
Symfony\Component\Mailer\Transport::fromDsn() (Line: 135)
Drupal\symfony_mailer\Mailer->doSend() (Line: 91)
Drupal\symfony_mailer\Mailer->Drupal\symfony_mailer\{closure}() (Line: 578)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 92)
Drupal\symfony_mailer\Mailer->send() (Line: 349)
Drupal\symfony_mailer\Email->send() (Line: 74)
Drupal\symfony_mailer_bc\MailManagerReplacement->mail() (Line: 1207)
Drupal\webform\Plugin\WebformHandler\EmailWebformHandler->sendMessage() (Line: 856)
Drupal\webform\Plugin\WebformHandler\EmailWebformHandler->postSave() (Line: 2741)
Drupal\webform\Entity\Webform->invokeHandlers() (Line: 1211)
Drupal\webform\WebformSubmissionStorage->invokeWebformHandlers() (Line: 1119)
Drupal\webform\WebformSubmissionStorage->doPostSave() (Line: 455)
Drupal\Core\Entity\EntityStorageBase->save() (Line: 801)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (Line: 982)
Drupal\webform\WebformSubmissionStorage->save() (Line: 339)
Drupal\Core\Entity\EntityBase->save() (Line: 887)
Drupal\webform\Entity\WebformSubmission->save() (Line: 1972)
Drupal\webform\WebformSubmissionForm->save()
call_user_func_array() (Line: 113)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers() (Line: 51)
Drupal\Core\Form\FormSubmitter->doSubmitForm() (Line: 593)
Drupal\Core\Form\FormBuilder->processForm() (Line: 321)
Drupal\Core\Form\FormBuilder->buildForm() (Line: 48)
Drupal\Core\Entity\EntityFormBuilder->getForm() (Line: 1233)
Drupal\webform\Entity\Webform->getSubmissionForm() (Line: 76)
Drupal\webform\Controller\WebformEntityController->addForm()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 578)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 158)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 57)
Drupal\Core\StackMiddleware\Session->handle() (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 23)
Stack\StackedHttpKernel->handle() (Line: 717)
Drupal\Core\DrupalKernel->handle() (Line: 19)
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | Screenshot 2021-12-13 at 10.39.00.png | 34.75 KB | jeroent |
Issue fork symfony_mailer-3252985
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:
Comments
Comment #3
jeroentComment #4
jeroentComment #5
adamps commentedThanks looks good I have just one small question
Comment #6
jeroentI reverted the change.
Comment #7
adamps commentedThanks for the response. I tested the fix (it now needs a reroll which I hacked locally), and I think I found why you added the change you just reverted 😃.
Typed property Drupal\symfony_mailer\Email::$transportDsn must not be accessed before initializationThe "" mailer DSN must contain a scheme.getTransportDsn()if the field is NULL throw an exception something like thisMissing email transport: please configure a default.it could maybe even link to the config page??Comment #8
adamps commentedI plan to create a new release soon. If you would be ready to finish off this issue quite quickly then I can wait so that it is included - please let me know if you wish to do that.
Comment #9
jeroentI’ll try to update the MR on monday.
Comment #10
adamps commentedGreat many thanks. I realise my comment #7 was unclear. I think you had it almost right before I reviewed it - sorry😃. I think keep the code to initialise $transportDsn to '', as this ensures that
getTransportDsn()is safe to call anytime.Then the clearer error message in case of the transport being unset would presumably go in
Mailer::doSend()?? Anyway I'm sure that once you start coding it, then things will become clear.Comment #11
jeroentI updated the MR.
I tried to add something like:
but the link doesn't get rendered in the warning message:

So for that reason I created a separate exception.
Comment #12
adamps commentedThanks, looks good - just one little thing to fix
Comment #13
jeroentI updated the MR.
Comment #14
adamps commentedThanks