forked from audrey/intranet
read config from env var
This commit is contained in:
parent
889ea49a6d
commit
b7b28293b9
@ -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
|
||||
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"
|
||||
@ -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
|
||||
{
|
||||
$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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user