0

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

dev_php_js
  • 19
  • 2
  • I found this issue https://stackoverflow.com/questions/48915515/symfony-4-swiftmailer-gmail-email-not-sent but my problem is not resolved – dev_php_js Apr 29 '21 at 13:19
  • MAILER_DSN=gmail+smtp://${MAILER_EMAIL}:${MAILER_PASSWORD}@default – Berthol Yvano May 01 '21 at 01:19
  • With gmail you will have to deactivate the security to authorize an external application to send emails. https://myaccount.google.com/lesssecureapps – Berthol Yvano May 01 '21 at 01:23

0 Answers0