Operating mode in the admin (test mode sends all mail to a test recipient until switched live), bot protection for booking requests, mail rendering tests, mail:test command

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lars StommerandClaude Opus 5.5 committed 2026-10-22 23:01:44 +02:00
1 parent fdcb68d578
commit d018c97be4
22 files changed
+698 -23

No files matched your search

+47
View File
@@ -0,0 +1,47 @@
<?php
namespace App\Console\Commands;
use App\Support\Settings;
use Illuminate\Console\Attributes\Description;
use Illuminate\Console\Attributes\Signature;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Mail;
use Throwable;
#[Signature('mail:test {to? : Empfänger (Standard: Benachrichtigungsadresse)}')]
#[Description('Send a test e-mail through the configured mailer and report delivery errors (e.g. SMTP login)')]
class SendTestMail extends Command
{
/**
* Execute the console command.
*/
public function handle(): int
{
$to = (string) ($this->argument('to') ?: config('fewo.notification_email'));
$mailer = (string) config('mail.default');
$redirect = Settings::mailRedirect();
$this->line("Versandweg: {$mailer}".($mailer === 'smtp' ? ' ('.config('mail.mailers.smtp.host').':'.config('mail.mailers.smtp.port').')' : '').' · Absender: '.config('mail.from.address'));
if (filled($redirect)) {
$this->line("Umleitung aktiv: die Mail geht an {$redirect} statt an {$to}.");
}
if ($mailer === 'log') {
$this->warn('Versandweg "log": es wird nichts zugestellt. Zum echten Versand MAIL_MAILER=smtp und MAIL_PASSWORD setzen (docs/BETRIEB.md §5a).');
}
try {
Mail::raw("Testmail der Ferienwohnung Stommer\n\nGesendet am ".now()->format('d.m.Y H:i:s').' von '.config('app.url').".\nWenn diese Mail ankommt, funktioniert der Versand.", function ($message) use ($to): void {
$message->to($to)->subject('Testmail Ferienwohnung Stommer – '.now()->format('d.m.Y H:i'));
});
} catch (Throwable $exception) {
$this->error('Versand fehlgeschlagen: '.$exception->getMessage());
return self::FAILURE;
}
$this->info('Übergeben an den Mailserver – bitte Posteingang (und Spam-Ordner) prüfen.');
return self::SUCCESS;
}
}