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

Flash message showing error is not submitted if sending of email fails (in case of exception) #1100

Open
sypets opened this issue Aug 13, 2024 · 1 comment

Comments

@sypets
Copy link
Contributor

sypets commented Aug 13, 2024

This is related to #1087, but not the same issue. In fact, to solve #1087 I am using a patched version.

Reproduce

  1. Use email configuration with smtp (most likely for this to work, we need synchronous sending of mail without mail queue)
  2. make sure flash messages are displayed properly, e.g .with fix [BUGFIX] Use correct queue identifier for flashmessages #1092 (or just debug to make sure flash messages are not submitted)
  3. create simple form with a field which is marked as sender email

image

  1. Now fill out form in FE and use a wrong email address

image

  • Expected result: After sending the form, I would expect an error message.
  • Actual result: no error message, only log message in error log (logging framework)

I do have a log message, so I know an exception is thrown:

Tue, 13 Aug 2024 15:31:18 +0200 [CRITICAL] request="97db7bed8235d" component="In2code.Powermail.Controller.FormController": Mail could not be sent - {"0":"Expected response code \"250/251/252\" but got code \"550\", with message \"550 5.1.1 <fehlerhafte-email@whatever-this-is-wrong.de>... User unknown\".","url":"https://mysite.de/test/powermail/powermail-einfaches-formular_intranet?tx_powermail_pi1%5Baction%5D=checkCreate&tx_powermail_pi1%5Bcontroller%5D=Form&cHash=ff72d9da8605e047124607eb4cc8e6c1"}

Possible fix

Fix in FormController:sendMailPreflight

         } catch (Throwable $exception) {
             $logger = ObjectUtility::getLogger(__CLASS__);
             $logger->critical('Mail could not be sent', [$exception->getMessage()]);
+            $this->addFlashMessage(
+                LocalizationUtility::translate('error_mail_not_created'),
+                '',
+                \TYPO3\CMS\Core\Type\ContextualFeedbackSeverity::ERROR
+            );
+            $this->messageClass = 'error';
         }

https://github.com/in2code-de/powermail/blob/master/Classes/Controller/FormController.php#L394

image

(ideally a more specific message would be displayed - we know email sending failed and we could even differentiate between mail to sender and mail to receiver.)

Versions

  • TYPO3 12.4.18
  • powermail (latest release): 12.3.5
@sypets
Copy link
Contributor Author

sypets commented Aug 13, 2024

Additionally: Ideally a more specific message would be displayed - we know email sending failed and we could even differentiate between mail to sender and mail to receiver.

@sypets sypets changed the title Flash message showing error is not submitted if sending of email fails Flash message showing error is not submitted if sending of email fails (in case of exception) Aug 13, 2024
@mschwemer mschwemer self-assigned this Aug 15, 2024
@mschwemer mschwemer removed their assignment Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants