diff --git a/.env-prod b/.env-prod index 810569a..89ae291 100644 --- a/.env-prod +++ b/.env-prod @@ -1,6 +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://smtp.jv.com:25 \ No newline at end of file +#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 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 diff --git a/templates/complaint.html.twig b/templates/complaint.html.twig index 91e95aa..1a76d83 100644 --- a/templates/complaint.html.twig +++ b/templates/complaint.html.twig @@ -10,20 +10,22 @@
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 completely anonymous so complaints cannot be traced to a specific person.
Feel free to submit any problem or concern.