src/Sulu/Bundle/SecurityBundle/Controller/ResettingController.php
private function sendTokenEmail(UserInterface $user, $from, $to)
    {
        if (null === $user->getPasswordResetToken()) {
            throw new NoTokenFoundException($user);
        }

        $maxNumberEmails = $this->getParameter('sulu_security.reset_password.mail.token_send_limit');

        if ($user->getPasswordResetTokenEmailsSent() === $maxNumberEmails) {
            throw new TokenEmailsLimitReachedException($maxNumberEmails, $user);
        }
        $mailer = $this->get('mailer');
        $em = $this->getDoctrine()->getManager();
        $message = $mailer->createMessage()->setSubject(
                $this->getSubject()
            )->setFrom($from)->setTo($to)->setBody(
                $this->getMessage($user)
            );
        $mailer->send($message);
        $user->setPasswordResetTokenEmailsSent($user->getPasswordResetTokenEmailsSent() + 1);
        $em->persist($user);
        $em->flush();
    }
private function sendTokenEmail(UserInterface $user, $from, $to)
    {
        if (null === $user->getPasswordResetToken()) {
            throw new NoTokenFoundException($user);
        }

        $maxNumberEmails = $this->getParameter('sulu_security.reset_password.mail.token_send_limit');

        if ($user->getPasswordResetTokenEmailsSent() === $maxNumberEmails) {
            throw new TokenEmailsLimitReachedException($maxNumberEmails, $user);
        }
        $mailer = $this->get('mailer');
        $em = $this->getDoctrine()->getManager();
        $message = $mailer->createMessage()->setSubject(
                $this->getSubject()
            )->setFrom($from)->setTo($to)->setBody(
                $this->getMessage($user)
            );
        $mailer->send($message);
        $user->setPasswordResetTokenEmailsSent($user->getPasswordResetTokenEmailsSent() + 1);
        $em->persist($user);
        $em->flush();
    }
private function sendTokenEmail ( UserInterface $ user , $ from , $ to ) { if ( null === $ user -> getPasswordResetToken ( ) ) { throw new NoTokenFoundException ( $ user ) ; } $ maxNumberEmails = $ this -> getParameter ( 'sulu_security.reset_password.mail.token_send_limit' ) ; if ( $ user -> getPasswordResetTokenEmailsSent ( ) === $ maxNumberEmails ) { throw new TokenEmailsLimitReachedException ( $ maxNumberEmails , $ user ) ; } $ mailer = $ this -> get ( 'mailer' ) ; $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ message = $ mailer -> createMessage ( ) -> setSubject ( $ this -> getSubject ( ) ) -> setFrom ( $ from ) -> setTo ( $ to ) -> setBody ( $ this -> getMessage ( $ user ) ) ; $ mailer -> send ( $ message ) ; $ user -> setPasswordResetTokenEmailsSent ( $ user -> getPasswordResetTokenEmailsSent ( ) + 1 ) ; $ em -> persist ( $ user ) ; $ em -> flush ( ) ; }
Sends the password-reset-token of a user to an email-adress.

@param UserInterface $user
@param string $from From-Email-Address
@param string $to To-Email-Address

@throws NoTokenFoundException
@throws TokenEmailsLimitReachedException
Sends the password - reset - token of a user to an email - adress .