0

i have some probleme using swiftmailer for setting my confirmation email, normaly everything is set well, but the mail is not sent, and i have my user in my database (but enable is set to 0 of course).

Since i don't have errors show by symfony i suppose it's my gmail account that blocked them, but i already set it to allow other application to use it as a "server", and i have a page that use swiftmailer to send normal mail, and it work fine.

i'm lost, thanks for your future help

My config.yml :

 swiftmailer:
   transport: %mailer_transport%
   host:      %mailer_host%
   username:  %mailer_user%
   password:  %mailer_password%
   encryption: ssl

fos_user:
    db_driver: orm
    firewall_name: main
    user_class: UserBundle\Entity\User
    service:
        mailer: fos_user.mailer.default
    registration:
            confirmation:
                enabled: true
     from_email:
            address:        maxime.duvey@gmail.com
            sender_name:    Registration mail

My config.yml :

    mailer_transport: gmail
mailer_host: 127.0.0.1
mailer_user: maxime.duvey@gmail.com
mailer_password: XXXXXXXXXXX

i'm really lost, i don't understand why it don't work

2 Answers2

0

It might be because you have to turn on "Less Secure Apps" as gmail allows doesn't allow you to access logins unless it is a secure app that they provide. This can be found in you google admin console.

See the link here for more info

I had the same problem when using PHPMailer.

However if you do decide to turn it on, it is not recommended.

They mention this in the link provided.

mp252
  • 453
  • 1
  • 6
  • 18
  • thanks for your rapid answer, but i already allowed them : http://puu.sh/q75x8.png i'm french, it just say that i allowed less securised applicasion to use this adress – Maxime Duvey Jul 19 '16 at 16:35
  • I see you are not using smtp. If you try and change to using smtp settings you should be able to connect like that. Here is another [link](http://stackoverflow.com/questions/3536836/trying-to-send-mail-using-swift-mailer-gmail-smtp-php) that shows how to set that up. Let me know how you get on. – mp252 Jul 19 '16 at 16:39
  • Actually this [link](http://swiftmailer.org/docs/sending.html) would be more appropriate I think. It's the swiftmailer documentation. If you change the ```smtp.example.org``` to ```smtp.gmail.com``` and then the username to your email address and password to your password. It should work. – mp252 Jul 19 '16 at 16:44
  • thanks again for the awnswer. but i can send direct mail with my gmail account i mean ia have a page that allow to send a mail, it work fine, it's the automatic mail send by symfony after a registration that never come. – Maxime Duvey Jul 19 '16 at 16:44
0

now that i think of it, it's maybe my manner to add a new user to my database :

my controler :

$userregister = new User();
  $formregister = $this->get('form.factory')->createBuilder(FormType::class, $userregister);
  $formregister
  ->add('firstname',      TextType::class)
  ->add('lastname',       TextType::class)
  ->add('email',          EmailType::class)
  ->add('phonehome',      NumberType::class)
  ->add('phoneportable',  NumberType::class)
  ->add('username',       TextType::class)
  //->add('Password',       PasswordType::class)
  ->add('plainPassword',  RepeatedType::class, array(
        'type' =>         PasswordType::class,
        'first_options'  => array('label' => 'Password'),
        'second_options' => array('label' => 'Repeat Password'),
        ))
  ->add('submit',         SubmitType::class);

  $form = $formregister->getForm();
  $form->handleRequest($request);
         if ($form->isSubmitted() && $form->isValid())
          {
            $em = $this->getDoctrine()->getManager();

            $em->persist($userregister);
            $em->flush();

            $request->getSession()->getFlashBag()->add('notice', 'Annonce bien enregistrée.');


            return $this->redirect($this->generateUrl('Contact_Action', array('id' => $userregister->getId())));
          }

  return $this->render('register.html.twig', array('form'=>$form->createView()));

and my twig :

{{ form(form) }}

i'm not sure, maybe