Fosuserbundle: The service "fos_user.mailer" has a dependency on a non-existent service "mailer"

Created on 18 Aug 2017  路  6Comments  路  Source: FriendsOfSymfony/FOSUserBundle

fos_user:
    db_driver: orm # other valid values are 'mongodb' and 'couchdb'
    firewall_name: main
    user_class: UserBundle\Entity\User
    from_email:
        address: 'mail.redington.co.in'
        sender_name: 'cloudsupport'

Most helpful comment

Hi there! What version of Symfony and FOSUserBundle are you using?

On freshly installed SF3.3 with Flex i had to set:

fos_user:
    db_driver: orm # other valid values are 'mongodb' and 'couchdb'
    firewall_name: main
    user_class: App\Entity\User
    from_email:
        address: '%env(MAILER_USER_ADDRESS)%'
        sender_name: '%env(MAILER_USER_NAME)%'
    service:
        mailer: 'fos_user.mailer.noop'
        # mailer: 'fos_user.mailer.twig_swift' # Works as well

to quite this error. It didn't however remove the problem.

Does your SwiftmailerBundle is properly configured?

All 6 comments

Hi there! What version of Symfony and FOSUserBundle are you using?

On freshly installed SF3.3 with Flex i had to set:

fos_user:
    db_driver: orm # other valid values are 'mongodb' and 'couchdb'
    firewall_name: main
    user_class: App\Entity\User
    from_email:
        address: '%env(MAILER_USER_ADDRESS)%'
        sender_name: '%env(MAILER_USER_NAME)%'
    service:
        mailer: 'fos_user.mailer.noop'
        # mailer: 'fos_user.mailer.twig_swift' # Works as well

to quite this error. It didn't however remove the problem.

Does your SwiftmailerBundle is properly configured?

without Swiftmailer bundle we can't use latest version ??

Sorry, my fault. SwiftmailerBundle is not required, but swiftmailer (library) is.

https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/composer.json#L35

How about your setup? What version of Symfony do you use? And how about flex? Did you try use 'fos_user.mailer.twig_swift' as in my snippet?

Cheers!

EDIT:
On the other hand, FOSUserBundle documentations says (in boxed paragraph):
https://symfony.com/doc/master/bundles/FOSUserBundle/emails.html#default-mailer-implementations

The fos_user.mailer.noop mailer service should be used in the case where you do not want the bundle to send emails and you do not want to include the SwiftmailerBundle in your app. If you leave the default implementation configured as the mailer and do not have the SwiftmailerBundle registered, you will receive an exception because of a missing dependency.

So maybe SwiftmailerBundle is required after all?

symfony:2.8.2,after install swiftmailerbundle its working fine.
but remove swiftmailerbundle its asking The service "fos_user.mailer" has a dependency on a non-existent service "mailer"

So here is our answer :)

As far as I know you can write your own mailer and get rid of SwiftmailerBundle:
https://symfony.com/doc/master/bundles/FOSUserBundle/emails.html#using-a-custom-mailer

@broiniac thanks a lot

Was this page helpful?
0 / 5 - 0 ratings