Problem/Motivation

If any other exception apart from an instance of TransportExceptionInterface when sending the email, a WSOD appears.

Steps to reproduce

Not sure how to reproduce this locally. For us it appears on platform.sh instances with outgoing emails disabled. For some reason then the transport method is switched to DSN which fails in \Symfony\Component\Mailer\Transport\Dsn::fromString with InvalidArgumentException.

I haven't investigated why it actually switches from SMTP (which is the default transport set by this module).

Proposed resolution

Add a fallback catch for \Exception

Remaining tasks

User interface changes

API changes

Data model changes

Comments

Primsi created an issue. See original summary.

primsi’s picture

Status: Active » Needs review
StatusFileSize
new731 bytes

Initial patch

mxr576’s picture

Just by reading the issue summary, I am unsure if this change is needed

DSN which fails in \Symfony\Component\Mailer\Transport\Dsn::fromString with InvalidArgumentException.

InvalidArgumentException is an unchecked exception, it is meant to stop execution to protect the system, IOW cause WSOD.

https://phpstan.org/blog/bring-your-exceptions-under-control

  • zengenuity committed 96c6c99e on 1.0.x authored by Primsi
    Issue #3396902 by Primsi: SymfonyMailer::mail should handle other...
zengenuity’s picture

Status: Needs review » Fixed

@Primsi, thanks for the patch. Committed.

@mxr576, I take your point about the exception stopping execution, but I think in this case, that's already happening, since we're at the very end of the mailing process, and we're returning FALSE to tell the rest of Drupal that it failed. I don't see any harm in triggering Drupal to display a nicely-formatted error message rather than crashing with a WSOD.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.