In my project Symfony I use Mailer component for send email but I found this error
Connection could not be established with host "ssl://smtp.gmail.com:465": stream_socket_client(): unable to connect to ssl://smtp.gmail.com:465 (Une tentative de connexion a échoué car le parti connecté n’a pas répondu convenablement au-delà d’une certaine durée ou une connexion établie a échoué car l’hôte de connexion n’a pas répondu.
code php in controller:
/**
* @Route("/send", name="send.mail")
*/
public function testSendMail(MailerInterface $mailer): Response{
$email = (new Email())
->from('test@gmail.com')
->to('test1@gmail.com')
//->cc('cc@example.com')
//->bcc('bcc@example.com')
//->replyTo('fabien@example.com')
//->priority(Email::PRIORITY_HIGH)
->subject('Time for Symfony Mailer!')
->text('Sending emails is fun again!')
->html('<p>See Twig integration for better HTML integration!</p>');
$mailer->send($email);
return new Response('send');
}
code configuratio in .env file:
MAILER_DSN=gmail://test@gmail.com:testpwd@localhost?encryption=tls&auth_mode=oauth
how to configure exactly to send mail