From 094ee2c3d6438d716e1b5f6ed5b88dadf09e142d Mon Sep 17 00:00:00 2001 From: Constantin Simonis Date: Thu, 23 Jan 2025 19:36:51 +0100 Subject: [PATCH] fix mailing --- .env | 1 + src/Service/ContactService.php | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.env b/.env index 755766b..84a41ab 100644 --- a/.env +++ b/.env @@ -22,4 +22,5 @@ APP_SECRET= ###> symfony/mailer ### MAILER_DSN=smtp://${MAILER_USER:-null}:${MAILER_PASSWORD:-null}@${MAILER_HOST:-localhost}:${MAILER_PORT:-1025} CONTACT_MAIL=${CONTACT_MAIL:-contact@localhost} +SENDER_MAIL=${SENDER_MAIL:-noreply@localhost} ###< symfony/mailer ### diff --git a/src/Service/ContactService.php b/src/Service/ContactService.php index 82dbefc..2bc0c4a 100644 --- a/src/Service/ContactService.php +++ b/src/Service/ContactService.php @@ -13,6 +13,8 @@ final readonly class ContactService private MailerInterface $mailer, #[Autowire(env: 'CONTACT_MAIL')] private string $contactEmail, + #[Autowire(env: 'SENDER_MAIL')] + private string $senderEmail, ){ } @@ -22,7 +24,7 @@ final readonly class ContactService ->htmlTemplate('email/contact.html.twig') ->context(['data' => $data]) ->subject('Kontakt aufnahme') - ->from($data->email) + ->from($this->senderEmail) ->to($this->contactEmail); $this->mailer->send($mail);