protected function sendConfirmation($mailer, User $user)
 {
     $templating = $this->getContainer()->get('templating');
     $body = $templating->render('GotChosenSiteBundle:Emails:disabled_user.txt.twig', array('user' => $user));
     $message = \Swift_Message::newInstance()->setSubject('GotChosen: User account for e-mail "' . $user->getEmail() . '" has been cancelled')->setFrom('*****@*****.**', 'GotChosen')->setTo($user->getEmail())->setBody($body);
     $mailer->send($message);
 }
 protected function sendConfirmation($mailer, User $user)
 {
     $router = $this->getContainer()->get('router');
     $templating = $this->getContainer()->get('templating');
     $router->setContext(new RequestContext('', 'GET', 'www.gotchosen.com', 'https'));
     $params = ['token' => $user->getConfirmationToken()];
     $url = $router->generate('fos_user_resetting_reset', $params, true);
     $rendered = $templating->render('FOSUserBundle:Resetting:email.txt.twig', array('user' => $user, 'confirmationUrl' => $url));
     // Render the email, use the first line as the subject, and the rest as the body
     $renderedLines = explode("\n", trim($rendered));
     $subject = $renderedLines[0];
     $body = implode("\n", array_slice($renderedLines, 1));
     $message = \Swift_Message::newInstance()->setSubject($subject)->setFrom('*****@*****.**', 'GotChosen')->setTo($user->getEmail())->setBody($body);
     $mailer->send($message);
     $user->setPasswordRequestedAt(new \DateTime());
     $this->getContainer()->get('fos_user.user_manager')->updateUser($user);
 }
 protected function sendReconfirmationEmail(User $user)
 {
     $params = ['token' => $user->getConfirmationToken()];
     $url = $this->generateUrl('profile_reconfirm', $params, true);
     $body = $this->renderView('GotChosenSiteBundle:Emails:email_changed.txt.twig', array('user' => $user, 'confirmationUrl' => $url));
     $msg = \Swift_Message::newInstance('GotChosen: Email confirmation request for "' . $user->getEmail() . '"')->setFrom("*****@*****.**", 'GotChosen - automated message, do not reply')->setTo($user->getEmail())->setBody($body, 'text/plain');
     $this->mailer()->send($msg);
 }
 protected function sendConfirmationEmailMessage(User $user, $customTarget)
 {
     $params = ['token' => $user->getConfirmationToken()];
     if ($customTarget) {
         $params['_target'] = $customTarget;
     }
     $url = $this->generateUrl('fos_user_registration_confirm', $params, true);
     $rendered = $this->renderView('FOSUserBundle:Registration:email.txt.twig', array('user' => $user, 'confirmationUrl' => $url));
     // Render the email, use the first line as the subject, and the rest as the body
     $renderedLines = explode("\n", trim($rendered));
     $subject = $renderedLines[0];
     $body = implode("\n", array_slice($renderedLines, 1));
     $message = \Swift_Message::newInstance()->setSubject($subject)->setFrom('*****@*****.**', 'GotChosen - automated message, do not reply')->setTo($user->getEmail())->setBody($body);
     $this->get('mailer')->send($message);
 }