+ //Set mail shortcut
+ $mail =& $this->config['recover_mail']['mail'];
+
+ //Regen hash
+ $hash = $slugger->hash($encoded);
+
+ //Generate each route route
+ foreach($this->config['recover_mail']['route'] as $route => $tag) {
+ //Only process defined routes
+ if (empty($mail['context'][$tag]) && !empty($this->config['route'][$route])) {
+ //Process for recover mail url
+ if ($route == 'recover_mail') {
+ //Prepend recover context with tag
+ $this->config['route'][$route]['context'] = [
+ 'recipient' => $recipient,
+ 'hash' => $hash
+ ]+$this->config['route'][$route]['context'];
+ }
+ //Set the url in context
+ $mail['context'][$tag] = $this->get('router')->generate(
+ $this->config['route'][$route]['name'],
+ $this->config['route'][$route]['context'],
+ UrlGeneratorInterface::ABSOLUTE_URL
+ );
+ }
+ }
+
+ //Set recipient_name
+ $mail['context']['recipient_mail'] = $user->getMail();
+
+ //Set recipient_name
+ $mail['context']['recipient_name'] = trim($user->getForename().' '.$user->getSurname().($user->getPseudonym()?' ('.$user->getPseudonym().')':''));
+
+ //Init subject context
+ $subjectContext = [];
+
+ //Process each context pair
+ foreach($mail['context']+$this->config['recover_mail']['view']['context'] as $k => $v) {
+ //Reinsert each context pair with the key surrounded by %
+ $subjectContext['%'.$k.'%'] = $v;
+ }
+
+ //Translate subject
+ $mail['subject'] = ucfirst($this->translator->trans($mail['subject'], $subjectContext));
+
+ //Create message
+ $message = (new TemplatedEmail())
+ //Set sender
+ ->from(new Address($this->config['contact']['mail'], $this->config['contact']['name']))
+ //Set recipient
+ //XXX: remove the debug set in vendor/symfony/mime/Address.php +46
+ ->to(new Address($mail['context']['recipient_mail'], $mail['context']['recipient_name']))
+ //Set subject
+ ->subject($mail['subject'])
+
+ //Set path to twig templates
+ ->htmlTemplate($mail['html'])
+ ->textTemplate($mail['text'])
+
+ //Set context
+ ->context(['subject' => $mail['subject']]+$mail['context']+$this->config['recover_mail']['view']['context']);
+
+ //Try sending message
+ //XXX: mail delivery may silently fail
+ try {
+ //Send message
+ $mailer->send($message);
+
+ //Redirect on the same route with sent=1 to cleanup form
+ return $this->redirectToRoute($request->get('_route'), ['recipient' => $recipient, 'hash' => $hash, 'sent' => 1]+$request->get('_route_params'));
+ //Catch obvious transport exception
+ } catch(TransportExceptionInterface $e) {
+ //Add error message mail unreachable
+ $form->get('password')->get('first')->addError(new FormError($this->translator->trans('Account password updated but unable to contact: %mail%', array('%mail%' => $mail['context']['recipient_mail']))));