From b7b28293b91b6a8cc08880e6d81c9d630722fef3 Mon Sep 17 00:00:00 2001 From: Audrey Jensen Date: Tue, 25 Jul 2023 20:35:06 +0000 Subject: [PATCH 1/5] read config from env var --- .env-prod | 5 ++++- src/Controller/ComplaintController.php | 27 ++++++-------------------- 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/.env-prod b/.env-prod index 810569a..e5c115b 100644 --- a/.env-prod +++ b/.env-prod @@ -3,4 +3,7 @@ APP_SECRET=ba16d9b24f329be32408d0a9dc24a534 RP_DATABASE_URL=sqlite:///%kernel.project_dir%/RPCopy/CRParchive.db SP_DATABASE_URL=sqlite:///%kernel.project_dir%/RPCopy/CSParchive.db MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0 -MAILER_DSN=smtp://smtp.jv.com:25 \ No newline at end of file +MAILER_DSN=smtp://jv-com.mail.protection.outlook.com:25 +MAILER_DSN=smtp://jv-com.mail.protection.outlook.com:25 +//COMPLAINT_RECIPIENT_EMAIL=chris@jv.com +//COMPLAINT_RECIPIENT_NAME="Chris Weiser" \ No newline at end of file diff --git a/src/Controller/ComplaintController.php b/src/Controller/ComplaintController.php index dd4af36..5286667 100644 --- a/src/Controller/ComplaintController.php +++ b/src/Controller/ComplaintController.php @@ -23,38 +23,23 @@ class ComplaintController extends AbstractController { $form = $this->createForm(AnonymousComplaintType::class); $form->handleRequest($request); + if($form->isSubmitted()) { $message = $form->get('Message')->getData(); - $email = (new Email()) - ->from(new Address('noreply@jv.com', 'Anonymous')) - ->to('ajensen@jv.com') //Send to me for testing purposes. TODO: change to chris@jv.com to be read from a config or env - ->subject('Anonymous Contact Form') - ->text($message); - $email->getHeaders()->addTextHeader('X-Auto-Response-Suppress', 'OOF, DR, RN, NRN, AutoReply'); //Tell autoresponders to not reply - try - { - - $log->Debug('Send email!'); - $mailer->send($email); //FIXME: Emails aren't sending for some reason - $isSubmitted = true; - } - catch (TransportExceptionInterface $e) - { - $isSubmitted = false; - } + $sendMail = $this->sendEmail($mailer, $message, $log); } - else + else { - $isSubmitted = null; + $sendMail = null; } - return $this->render('complaint.html.twig',['form' => $form, 'isSubmitted' => $isSubmitted]); + return $this->render('complaint.html.twig',['form' => $form, 'isSubmitted' => $sendMail, 'complaintReceiverName' => $_SERVER['COMPLAINT_RECIPIENT_NAME']]); } public function sendEmail(TransportTransportInterface $mailer, string $message, LoggerInterface $log) : bool { $email = (new Email()) ->from(new Address('noreply@jv.com', 'Anonymous')) - ->to('ajensen@jv.com') //Send to me for testing purposes. TODO: change to chris@jv.com + ->to($_SERVER['COMPLAINT_RECIPIENT_ADDRESS']) //Send to me for testing purposes. TODO: change to chris@jv.com ->subject('Anonymous Contact Form') ->text($message); $email->getHeaders()->addTextHeader('X-Auto-Response-Suppress', 'OOF, DR, RN, NRN, AutoReply'); //Tell autoresponders to not reply From d59729bb05f46a3d6ae110164a27e8a8401030dc Mon Sep 17 00:00:00 2001 From: Audrey Jensen Date: Tue, 25 Jul 2023 20:35:18 +0000 Subject: [PATCH 2/5] list recipient's name --- templates/complaint.html.twig | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/templates/complaint.html.twig b/templates/complaint.html.twig index 91e95aa..14d5004 100644 --- a/templates/complaint.html.twig +++ b/templates/complaint.html.twig @@ -10,7 +10,7 @@

Instructions

Type your complaint or problem into the message box below and click "Submit". -
Messages will be sent directly to Chris Weiser's email account. +
Messages will be sent directly to {{ complaintReceiverName }}'s email account.
Messages will be completely anonymous so complaints cannot be traced to a specific person.
Feel free to submit any problem or concern.

@@ -23,7 +23,6 @@
Form failed to submit with errors
{% endif %} {% else %} - Nah this broke //TODO: remove after debugging {% endif %} From da763bad202a6e42c2b55eeb1680d50a0912f00c Mon Sep 17 00:00:00 2001 From: Audrey Jensen Date: Tue, 25 Jul 2023 20:38:40 +0000 Subject: [PATCH 3/5] add PII warning --- templates/complaint.html.twig | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/templates/complaint.html.twig b/templates/complaint.html.twig index 14d5004..a73bc42 100644 --- a/templates/complaint.html.twig +++ b/templates/complaint.html.twig @@ -11,8 +11,11 @@

Type your complaint or problem into the message box below and click "Submit".
Messages will be sent directly to {{ complaintReceiverName }}'s email account. -
Messages will be completely anonymous so complaints cannot be traced to a specific person.
Feel free to submit any problem or concern.

- +
Messages will be completely anonymous so complaints cannot be traced to a specific person. +
Feel free to submit any problem or concern. +
Note: If you add personally identifying information (such as your name) then this won't be anonymous. Avoid this, unless you want your identity to be known +

+ {{ form(form) }}
From da76456d44ff05b683600ea458975ec8a8d415a8 Mon Sep 17 00:00:00 2001 From: Audrey Jensen Date: Tue, 25 Jul 2023 20:47:52 +0000 Subject: [PATCH 4/5] remove duplicate MAILER_DSN --- .env-prod | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.env-prod b/.env-prod index e5c115b..89ae291 100644 --- a/.env-prod +++ b/.env-prod @@ -1,9 +1,11 @@ APP_ENV=prod -APP_SECRET=ba16d9b24f329be32408d0a9dc24a534 +APP_SECRET=ba16d9b24f329be32408d0a9dc24a534 #Nothing. We're an open book and have no secrets +#Ticket Database file URIs. RP_DATABASE_URL=sqlite:///%kernel.project_dir%/RPCopy/CRParchive.db SP_DATABASE_URL=sqlite:///%kernel.project_dir%/RPCopy/CSParchive.db -MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0 -MAILER_DSN=smtp://jv-com.mail.protection.outlook.com:25 +#Email Settings +MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0 #Leave this alone unless you know what you're doing MAILER_DSN=smtp://jv-com.mail.protection.outlook.com:25 +#Anonymous Complaints Email Settings //COMPLAINT_RECIPIENT_EMAIL=chris@jv.com //COMPLAINT_RECIPIENT_NAME="Chris Weiser" \ No newline at end of file From c498a91aa4de21ad6d0f9a6207e8450dbe3f6155 Mon Sep 17 00:00:00 2001 From: Audrey Jensen Date: Tue, 25 Jul 2023 20:48:03 +0000 Subject: [PATCH 5/5] move form into container --- templates/complaint.html.twig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/complaint.html.twig b/templates/complaint.html.twig index a73bc42..1a76d83 100644 --- a/templates/complaint.html.twig +++ b/templates/complaint.html.twig @@ -17,13 +17,13 @@

- {{ form(form) }}
+ {{ form(form) }} {% if isSubmitted != null %} {% if isSubmitted %} -
Form submitted successfully
+
Email sent successfully
{% else %} -
Form failed to submit with errors
+
Form/email failed to submit with errors. Contact IT
{% endif %} {% else %} {% endif %}