Formular-Infrastruktur: Contact/Demo/Helpdesk mit E-Mail- und Salesforce-Delivery, JSON-Renderer-Erweiterungen, Crop-Variants

Build-Artefakte in public/_frontend/assets nicht enthalten.
This commit is contained in:
orasche committed 2026-07-30 13:12:45 +02:00
1 parent eae40f4286
commit a739dd8fe3
51 files changed
+1598 -303

No files matched your search

+48
View File
@@ -0,0 +1,48 @@
<?php
declare(strict_types=1);
namespace Evomedien\Vitec\Forms\Delivery;
use TYPO3\CMS\Core\Mail\MailMessage;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* Sends the submission as a plain-text mail to the FlexForm-configured
* recipient(s). Sender = system default (MAIL settings); reply-to = the
* submitter's email when present.
*/
final class EmailDelivery implements DeliveryInterface
{
public function deliver(string $formKey, array $payload, array $settings): void
{
$recipients = GeneralUtility::trimExplode(',', (string)($settings['recipient'] ?? ''), true);
if ($recipients === []) {
throw new \RuntimeException('No recipient configured in the form plugin (FlexForm "Recipient").');
}
$subject = trim((string)($settings['subject'] ?? ''));
if ($subject === '') {
$subject = 'VITEC website form: ' . $formKey;
}
$lines = [];
foreach ($payload as $field => $value) {
$lines[] = str_pad($field . ':', 16) . $value;
}
$mail = GeneralUtility::makeInstance(MailMessage::class);
$mail->to(...$recipients)
->subject($subject)
->text("Form: $formKey\n\n" . implode("\n", $lines));
$submitterEmail = trim((string)($payload['email'] ?? ''));
if ($submitterEmail !== '' && filter_var($submitterEmail, FILTER_VALIDATE_EMAIL)) {
$mail->replyTo($submitterEmail);
}
if (!$mail->send()) {
throw new \RuntimeException('MailMessage::send() reported failure.');
}
}
}