From b8d779e1b7bc27173708de088267b6668ee8dd59 Mon Sep 17 00:00:00 2001 From: Felix Zandanel Date: Wed, 30 Jul 2025 10:15:54 +0200 Subject: [PATCH 1/3] chore: Add conflict declaration to composer.json targeting "neos/swiftmailer" --- composer.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/composer.json b/composer.json index c3c0b1c..fb854c5 100644 --- a/composer.json +++ b/composer.json @@ -10,6 +10,9 @@ "neos/fluid-adaptor": "^8.3" }, "suggest": {}, + "conflict": { + "neos/swiftmailer": "*" + }, "autoload": { "psr-4": { "FormatD\\Mailer\\": "Classes/" From becb8724b2f25fc16d2e9c580675344f44b8b662 Mon Sep 17 00:00:00 2001 From: Felix Zandanel Date: Fri, 5 Dec 2025 10:51:43 +0100 Subject: [PATCH 2/3] chore: Support query params when contructing DSN in `fd-mailer` transport --- Classes/Transport/FdMailerTransport.php | 14 ++++++--- README.md | 38 +++++++++++++++++++------ 2 files changed, 40 insertions(+), 12 deletions(-) diff --git a/Classes/Transport/FdMailerTransport.php b/Classes/Transport/FdMailerTransport.php index cbeab52..7d835a2 100644 --- a/Classes/Transport/FdMailerTransport.php +++ b/Classes/Transport/FdMailerTransport.php @@ -8,7 +8,6 @@ use Symfony\Component\Mailer\SentMessage; use Symfony\Component\Mailer\Transport; use Symfony\Component\Mailer\Transport\TransportInterface; -use Symfony\Component\Mime\Email; use Symfony\Component\Mime\RawMessage; class FdMailerTransport implements TransportInterface @@ -35,7 +34,7 @@ public function send(RawMessage $message, ?Envelope $envelope = null): ?SentMess protected function getActualTransportDsn(): string { $config = $this->settings['smtpTransport'] ?? null; - if ($config === null) { + if (!is_array($config)) { throw new \Exception('Missing FormatD.Mailer settings.'); } @@ -43,7 +42,9 @@ protected function getActualTransportDsn(): string throw new \Exception('Missing configuration: FormatD.Mailer.smtpTransport.host'); } - $scheme = ($config['encryption'] ?? false) ? 'smtps' : 'smtp'; + $useTlsChannel = $config['encryption'] ?? null; + $useTlsChannel = (bool)($useTlsChannel === 'false' || (string)$useTlsChannel === '0' ? false : $useTlsChannel); + $scheme = $useTlsChannel ? 'smtps' : 'smtp'; $credentials = ''; if (($config['username'] ?? null) && ($config['password'] ?? null)) { @@ -53,7 +54,12 @@ protected function getActualTransportDsn(): string $host = $config['host']; $port = ($config['port'] ?? null) ? ':' . $config['port'] : ''; - return $scheme . '://' . $credentials . $host . $port; + $query = ''; + if (is_array($config['options'] ?? null)) { + $query = http_build_query($config['options'], '', '&'); + } + + return $scheme . '://' . $credentials . $host . $port . ($query ? '?' . $query : ''); } public function __toString(): string diff --git a/README.md b/README.md index 5c4f54b..092ca77 100644 --- a/README.md +++ b/README.md @@ -23,11 +23,11 @@ Releases und compatibility: | Package-Version | Neos Flow Version | `neos/form` Version | |-----------------|-------------------|---------------------| -| 2.0.0 | >= 8.x | >= 6.0.0 | +| 2.0.x | >= 8.x | >= 6.0.0 | | 1.1.x | >= 6.x | < 6.0.0 | | 1.0.x | 4.x - 5.x | < 6.0.0 | -## Using the service in you own plugins to use fluid templates for mails +## Using the service in your own plugins to use fluid templates for mails Configure default from address: @@ -88,6 +88,9 @@ Use the special DSN `fd-mailer` in the SymfonyMailer configuration. This transpo given under `FormatD.Mailer.smtpTransport` to build the actual DSN and actual SmtpTransport object. `host` is mandatory, all other parts are optional. +For special cases the automatic DSN construction can be omitted by passing the DSN directly at +`Neos.SymfonyMailer.mailer.dsn`. + ``` Neos: SymfonyMailer: @@ -97,9 +100,28 @@ Neos: FormatD: Mailer: smtpTransport: - host: '' - encryption: '' - port: '' - username: '' - password: '' -``` \ No newline at end of file + host: '%env:SMTP_HOST%' + encryption: '%env:SMTP_ENCRYPTION%' + port: '%env:SMTP_PORT%' + username: '%env:SMTP_USERNAME%' + password: '%env:SMTP_PASSWORD%' + + # Optional: Query params appended to the DSN, use with caution and only when necessary + options: + # Do not verify server TLS certificate + verify_peer: 0 + # Do not try `STARTTLS` at all + auto_tls: 'false' + # Use `STARTTLS` even when not announced in server capabilities + require_tls: 'true' + +``` + +The `encryption` param is cast to boolean, with `'false', '0', 0` being interpreted falsy as well. If true, the scheme +will be `smtps`, thus the Symfony SMTP transport tries to establish a TLS encrypted channel right away. If +`encryption` is false, then the transport will still try to upgrade the connection via `STARTTLS`, when that is +announced by the server! + +The `options` config is completely optional and could be omitted to use SymfonyMailer's sane defaults. It can be used to +define query parameters appended to the DSN, as described in +the [SymfonyMailer documentation](https://symfony.com/doc/current/mailer.html). \ No newline at end of file From 678b6f3c58925b592334450034e55175db8c8ad9 Mon Sep 17 00:00:00 2001 From: Felix Zandanel Date: Fri, 5 Dec 2025 10:59:07 +0100 Subject: [PATCH 3/3] chore: Support query params when constructing DSN in `fd-mailer` transport / cleanup --- Classes/Transport/FdMailerTransport.php | 2 +- README.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Classes/Transport/FdMailerTransport.php b/Classes/Transport/FdMailerTransport.php index 7d835a2..8a3cc3b 100644 --- a/Classes/Transport/FdMailerTransport.php +++ b/Classes/Transport/FdMailerTransport.php @@ -43,7 +43,7 @@ protected function getActualTransportDsn(): string } $useTlsChannel = $config['encryption'] ?? null; - $useTlsChannel = (bool)($useTlsChannel === 'false' || (string)$useTlsChannel === '0' ? false : $useTlsChannel); + $useTlsChannel = (bool)($useTlsChannel === 'false' ? false : $useTlsChannel); $scheme = $useTlsChannel ? 'smtps' : 'smtp'; $credentials = ''; diff --git a/README.md b/README.md index 092ca77..9626a51 100644 --- a/README.md +++ b/README.md @@ -117,8 +117,8 @@ FormatD: ``` -The `encryption` param is cast to boolean, with `'false', '0', 0` being interpreted falsy as well. If true, the scheme -will be `smtps`, thus the Symfony SMTP transport tries to establish a TLS encrypted channel right away. If +The `encryption` param is cast to boolean, with the `'false'` string being interpreted falsy as well. If true, the +scheme will be `smtps`, thus the Symfony SMTP transport tries to establish a TLS encrypted channel right away. If `encryption` is false, then the transport will still try to upgrade the connection via `STARTTLS`, when that is announced by the server!