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

Change order of mail to sender / receiver? #1110

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

Change order of mail to sender / receiver? #1110

sypets opened this issue Aug 27, 2024 · 1 comment

Comments

@sypets
Copy link
Contributor

sypets commented Aug 27, 2024

Currently, the mail to sender (which is the one filling out the form) is sent first. Then, the email to receiver is sent. This means, the sender gets a "confirmation" even before the (more crucial) email is sent.

I think it would be better to switch the order. Thus, if the mail to receiver fails, the "confirmation" will also not be sent.

I think it is a problem, if the user gets a confirmation but the actual sending to the receiver failed (because most people will then assume everything worked out smoothly).

This is a problem, especially in combination with flash messages not being displayed (see my other issues) and also in case the writing to the database is disabled (which I do not recommend but we have some rare cases where it is done due to data protection reasons).

FormController.::sendMailPreflight

try {
            if ($this->isSenderMailEnabled() && $this->mailRepository->getSenderMailFromArguments($mail)) {
                $mailPreflight = GeneralUtility::makeInstance(
                    SendSenderMailPreflight::class,
                    $this->settings,
                    $this->conf,
                    $this->request
                );
                $mailPreflight->sendSenderMail($mail);
            }
            if ($this->isReceiverMailEnabled()) {
                $mailPreflight = GeneralUtility::makeInstance(
                    SendReceiverMailPreflight::class,
                    $this->settings,
                    $this->request
                );
                $isSent = $mailPreflight->sendReceiverMail($mail, $hash);
                if ($isSent === false) {
                    $this->addFlashMessage(
                        LocalizationUtility::translate('error_mail_not_created'),
                        '',
                        \TYPO3\CMS\Core\Type\ContextualFeedbackSeverity::ERROR
                    );
                    $this->messageClass = 'error';
                }
            }
        } catch (Throwable $exception) {
            $logger = ObjectUtility::getLogger(__CLASS__);
            $logger->critical('Mail could not be sent', [$exception->getMessage()]);
        }

protected function sendMailPreflight(Mail $mail, string $hash = ''): void


Note: I have spent some hours following up on problem reports and analyzing every single problem. In general, the forms are very robust. We have about a 100 forms submitted per day and rarely there is a problem. However, if there is a problem, I would like to make sure that the person filling out the form does not assume everything worked out.

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

3 participants
@mschwemer @sypets and others