blahblah
blahblah

Reputation: 1018

FosUser: password email is not sending with template

I am trying to send password reset email. These are my configurations

fos_user:
    db_driver: orm
    firewall_name: main
    user_class: CoreBundle\Entity\User
    service:
            user_manager: pugx_user_manager
    registration:
            confirmation:
                enabled: true
                template: AppBundle:Email:registration.email.twig
                from_email:
                    address:        [email protected]
                    sender_name:    Hello
    resetting:
            token_ttl: 43200
            email:
                template: AppBundle:Email:password_reset.email.twig
                from_email:
                    address:        [email protected]
                    sender_name:    Hello

I tried to send emails by calling mailer service in controller:

  $this->get('fos_user.mailer')->sendResettingEmailMessage($testUser);

It doesn't work. However if I remove template, everything works fine. Emails are sent, but for me it's important to customise template.

My email settings are all good, registration confirm template customisation worked fine. I don't understand why resetting doesn't work

Upvotes: 2

Views: 826

Answers (1)

Gerard Vogels
Gerard Vogels

Reputation: 11

You should configure a different mailer service in the fos-user configuration, like:

   fos_user:
    db_driver: orm
    firewall_name: main
    user_class: AppBundle\Entity\User
    service:
        mailer: fos_user.mailer.twig_swift
    from_email:
        address: "%mailer_user%"
        sender_name: "%mailer_user%"
    registration:
        form:
            type: AppBundle\Form\RegistrationType
        confirmation:
            enabled: true
            template: email/registrationconfirmation.html.twig

Upvotes: 1

Related Questions