powermail
powermail copied to clipboard
Change order of mail to sender / receiver?
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()]);
}
https://github.com/in2code-de/powermail/blob/40c6b72247384edb633060c41e8253f6b0e2de69/Classes/Controller/FormController.php#L370
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.