FriendsOfSymfony / FOSUserBundle

Provides user management for your Symfony project. Compatible with Doctrine ORM & ODM, and custom storages.

Home Page:https://symfony.com/doc/master/bundles/FOSUserBundle/index.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

api-platform confirm email email address

dejanvujanovic opened this issue · comments

I have Symfony FOSUserBundle ~2.0 together with api-platform. I have created fos_user.yaml with following settings:

fos_user: db_driver: orm firewall_name: main user_class: App\Entity\User from_email: address: "example@example.com" sender_name: "example@example.com" registration: confirmation: enabled: true from_email: address: example@example.com sender_name: Demo Registration resetting: email: from_email: address: example@example.com sender_name: Demo Resetting service: mailer: fos_user.mailer.default
I am using swiftmailer to send emails with custom smtp and when I try to send email via command bin/console swiftmailer:email:send, email is sent, but when I try to register new user, the email is not sent at all. I have enabled intercept_redirects: true and inside web pofilerer, there is no log about email.

Email is sent if I use form to register user, using fosuser forms with default routing. But I need it when I create user with api-platform

Also I am using Symfony Flex 4.2

Anyone have some idea what could be the issue?

EDIT: Since FOSUserBundle uses events to handle sending email confirmation, I had to trigger manually FOSUserEvents::REGISTRATION_SUCCESS event. But to do this, I had to set 'fos_user.registration.form.factory' as public, so I could create form inside my event listener (listening for user creation), and then doing eventDispatch on the registration success.

Is there any cooler way to do this?

hi it since that i have the same problem

SF 4.2.2, FOSUser ~2.0

hi it since that i have the same problem

SF 4.2.2, FOSUser ~2.0

You can solve it with creating class and implementing EventSubscriberInterface. Try with
KernelEvents::VIEW => ['sendMail', EventPriorities::POST_WRITE] and then inside sendMail you can dispatch the registration_success event.

hi it since that i have the same problem
SF 4.2.2, FOSUser ~2.0

You can solve it with creating class and implementing EventSubscriberInterface. Try with
KernelEvents::VIEW => ['sendMail', EventPriorities::POST_WRITE] and then inside sendMail you can dispatch the registration_success event.

This issue can be closed, as the comment from above should be enough to solve this issue.