I'm a beginner with Symfony, and I have to put a Mailer in my web service. But I have a php exception that I don't understand.
There is my mailer function :
private function sendMail(MailerInterface $mailer, $p_leTI, $mail)
{
$pole = $p_leTI['pole'];
$type = $pole === 1 ? 'Logiciel' : ($pole === 2 ? 'Matériel' : 'Incident');
$client = $p_leTI['nomCli'];
$email = (new Email())
->from(new Address('random@gmail.com', 'Support Idéation Informatique'))
->to(new Address('random@gmail.com'))
->bcc(new Address('random@gmail.com'))
->subject("Ticket $type Site: $client")
->text("Client: $client\r\nObservation: {$p_leTI['OBSERVATION']}")
->html("<html lang='fr'>
<body>
<p>Demandeur: {$p_leTI['nomCli']}</p>
<p>Description: {$p_leTI['OBSERVATION']}</p>
<p>Téléphone: {$p_leTI['TEL']}</p>
<p>Email: {$p_leTI['EMAILCLIENT']}</p>
</body>
</html>");
$mailer->send($email);
$email = (new TemplatedEmail())
->from(new Address('random@gmail.com', 'Support Idéation Informatique'))
->bcc(new Address('random@gmail.com'))
->subject("Idéation Informatique - Votre demande a bien été enregistrée (Ticket n°" . $$p_leTI['IDTICKETINCIDENT'] . ")");
if (!empty($mail))
try {
$email->to(new Address($mail));
} catch (Exception $e) {
}
$email->htmlTemplate('emails/mail.html.twig')
->context([
'client' => $client,
'idticket' => $p_leTI['IDTICKETINCIDENT'],
'observation' => $p_leTI['OBSERVATION']
])
->text("Ouverture du ticket incident n°" . $p_leTI['IDTICKETINCIDENT'] . "\r\n" . $p_leTI['OBSERVATION']);
$mailer->send($email);
return true;
}
And there is the error in my log :
PHP Exception Symfony\Component\DependencyInjection\Exception\EnvNotFoundException: "Environment variable not found: "MAILER_DSN"."dency-injection/EnvVarProcessor.php
EnvVarProcessor.php is a file I never worked with so I don't understand, like I said I'm a beginner so I might have forgot something.
Thank's for you're help.