Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error handling when sending emails #258

Closed
rabauss opened this issue Apr 6, 2022 · 6 comments
Closed

Improve error handling when sending emails #258

rabauss opened this issue Apr 6, 2022 · 6 comments
Milestone

Comments

@rabauss
Copy link
Contributor

rabauss commented Apr 6, 2022

Unfortunately, errors when sending emails are not handled correctly, so the sender will see the success page, although an error occured.

The hook pocessFormData will only stop with exceptions:
https://github.com/contao/contao/blob/2f1827b8a2cac27d2b86d7ba6337470217d6c60d/core-bundle/src/Resources/contao/forms/Form.php#L563

But the NC catches all exceptions when trying to send emails:

\System::log(sprintf('Could not send email for message ID %s: %s', $objDraft->getMessage()->id, $e->getMessage()), __METHOD__, TL_ERROR);

Can we find a better solution for this bad error handling and user/customer experience?

@Toflar
Copy link
Member

Toflar commented Apr 6, 2022

I don't think we can all of a sudden throw the exceptions again.

@rabauss
Copy link
Contributor Author

rabauss commented Apr 6, 2022

That's true! Because of that I opened this issue so that it gets attention in v2 ☺️
Or maybe we can add better event in the core?

@Toflar
Copy link
Member

Toflar commented Apr 6, 2022

NC will require a complete rewrite which will be impossible without fundings.
Core: Sure, whatever you want to work on is appreciated :)

@rabauss
Copy link
Contributor Author

rabauss commented Jun 24, 2022

Some ideas up for discussion:

  • we add a new MailErrorEvent to the core
  • the MailErrorEvent can be dispatched in the notification center on errors/exceptions while executing the hook processFormData
  • after executing the hook processFormData there needs to be added a new listener or subscriber which handles the MailErrorEvent (I'm not sure if listener or subscriber is prefered by contao core)
  • in the event handler we could redirect to a new errorJumpTo (which needs to be added to the forms)

this feature would be nice for contao 5 :-)

@fritzmg
Copy link
Sponsor Collaborator

fritzmg commented Jun 27, 2022

this feature would be nice for contao 5 :-)

Only three days left for new features ;)

@Toflar
Copy link
Member

Toflar commented Dec 20, 2022

In version 2.0, all of this should be possible 😊 I'm thus closing it for myself so that I can keep track of all the issues. Feel free to revisit, once there's a public beta.

@Toflar Toflar closed this as completed Dec 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants