I know that fosUserBundle from Symfony can send EmailConfirmation automactly, just adding:
fos_user:
# ...
registration:
confirmation:
enabled: true
but i have my own register's form in my own controller. (I am NOT using register's form of FOSUSER). and i don't know how to send an emailconfirmation when an user register in my system.
these are my register's functions I am using:
public function index(Request $request)
{
$customer = new Customer();
$form = $this->createForm(CustomerType::class, $customer);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$pass = $form->get('password')->getData();
$email = $form->get('email')->getData();
$this->register($email, $email, $pass);
$em->persist($customer);
$em->flush($customer);
header("Refresh:0");
}
return $this->render('backend/customer/customer_register.html.twig', array('form' => $form->createView()));
}
and this Auxiliar Function:
private function register($email, $username, $password)
{
$userManager = $this->get('fos_user.user_manager');
$email_exist = $userManager->findUserByEmail($email);
if ($email_exist) {
return false;
}
$user = $userManager->createUser();
$user->setUsername($username);
$user->setEmail($email);
$user->setEmailCanonical($email);
$user->setEnabled(1);
$user->setPlainPassword($password);
$user->addRole('ROLE_CUSTOMER');
$userManager->updateUser($user);
return true;
}
I have tried using
$confirmationEnabled = $this->container->getParameter('fos_user.registration.confirmation.enabled');
but doesn't work
Please, I don't know how to start. it is neccessary to have any configuration of swift mailer?
if someone can help me I would appreciate it very much
Thanks, Thank you very much