Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony2 FosuserBundle: RE-send registration confirmation email

Framework PHP: Symfony2.6

Problem: I would like to add the following functionality to FosUserBundle: "The admin can re-send the registration confirmation email to a specific user" (in the admin section of the website).

I've already built the "user details" page where the admin can see all the information entered in the registration form and if the the user is enabled/confirmed. If the user is not enabled I will add a button to re-send the confirmation email.


Another solution is to to display a link to the user, after he tries to login with credentials that are not confirmed. Here is a similar question (that unfortunately has no feedback and it's not very clear to me and only covers the second approach):

https://stackoverflow.com/questions/25204877/re-sending-confirmation-email-fosuserbundle

Can you please point me towards the easiest and quickest solution?

like image 343
Igor Carmagna Avatar asked Jan 03 '15 08:01

Igor Carmagna


1 Answers

I know this an old question but today I came across the same problem and I found a simpler solution. Maybe this also helpful to others:

Simply ask the FOSUserBundle for its mailer and use it to re-send the message:

$mailer = $this->get('fos_user.mailer');                    
$mailer->sendConfirmationEmailMessage($user);

That's it! This will re-send an exact copy of the confirmation mail, since the same FOSUserBundle code is used. No need to manually re-create the message.

like image 190
Andrei Herford Avatar answered Oct 19 '22 11:10

Andrei Herford