Merge branch 'email'

This commit is contained in:
Audrey Jensen 2023-07-25 20:50:00 +00:00
commit 722135e945
3 changed files with 23 additions and 31 deletions

View File

@ -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
#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"

View File

@ -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

View File

@ -10,20 +10,22 @@
<h4 class="text-bold">Instructions</h4>
<p>Type your complaint or problem into the message box below and click "Submit".
<br>Messages will be sent directly to Chris Weiser's email account.
<br>Messages will be completely anonymous so complaints cannot be traced to a specific person. <br> Feel free to submit any problem or concern.</p>
<br>Messages will be sent directly to {{ complaintReceiverName }}'s email account.
<br>Messages will be completely anonymous so complaints cannot be traced to a specific person.
<br> Feel free to submit any problem or concern.
<br><strong>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</strong>
</p>
</div>
{{ form(form) }}
<div class="container">
{{ form(form) }}
{% if isSubmitted != null %}
{% if isSubmitted %}
<h5 class="alert alert-success"> Form submitted successfully </h5>
<h5 class="alert alert-success"> Email sent successfully </h5>
{% else %}
<h5 class="alert alert-danger"> Form failed to submit with errors </h5>
<h5 class="alert alert-danger"> Form/email failed to submit with errors. Contact IT </h5>
{% endif %}
{% else %}
Nah this broke //TODO: remove after debugging
{% endif %}
</div>
</body>