0

I'm trying to use Swiftmailer with Symfony 2.4.

Here is my config.yml :

# This file is auto-generated during the composer install
# parameters:
# mailer_transport: gmail
# mailer_host: smtp.gmail.com
# mailer_user: jules.truong.pro@gmail.com
# mailer_password: XXXXXX
# mailer_port: 465
# locale: fr
# secret: XXXX

And this is parameters.yml

# Swiftmailer Configuration
#  swiftmailer:
#     transport: %mailer_transport%
#     username:  %mailer_user%
#     password:  %mailer_password%

My code is pretty basic :

#   $request = $this->get('request');
#   $dataSubject = $request->query->get('lbSubject');
#   $dataEmail = $request->query->get('lbEmail');
#   $dataMessage = $request->query->get('lbMessage');
#   //Récupération du service
#    $mailer = $this->get('mailer');
#   
#   // Création de l'e-mail : le service mailer utilise SwiftMailer, donc nous créons une instance de Swift_Message
#    $message = \Swift_Message::newInstance()
#       ->setSubject($dataSubject)
#       ->setFrom($dataEmail)
#       ->setTo('julestruonglolilol@email.com')
#       ->setBody($dataMessage);
#
#   try 
#   {
#        if (!$mailer->send($message, $failures))
#        {
#           return new Response('Erreur' . $failures,400);
#        }
#        return new Response('OK',200);
#   }
#   catch(Exception $e)
#   {
#       return new Response('Erreur' . $failures,400);
#   }

At the end, it returns an error

Connection could not be established with host smtp.gmail.com

This is pretty offensive because i know my password .

After a few minutes, i receive and email that tells me that someone tried to hack my account etc ...

Oh and i'm running this with Wamp, so in local.

Is this my code that has a problem or Google maybe ?

Thanks

julio
  • 2,762
  • 4
  • 22
  • 34

1 Answers1

2

Try adding the following to your swiftmail configuration as GMail requires encryption/ssl connection

encryption: ssl
jmluy
  • 110
  • 1
  • 9
  • Apparently , it was not about encryption. The probleme is that gmail is restrictiv about sending email from app. I now use sendinblue as an smtp server – julio Nov 19 '14 at 17:10