有没有办法在没有邮件服务的情况下使用 FOSUserBundle

Is there a way to use the FOSUserBundle without a mailer service

我想使用 FOSUserBundle,但我的应用程序不需要邮件服务。无论如何我可以将它配置为不需要一个。 这是我的 fos 配置:

fos_user:
  db_driver: orm 
  firewall_name: main
  user_class: acmeBundle/Custom/User/Class

我试过这样配置它:

fos_user:
  db_driver: orm 
  firewall_name: main
  user_class: acmeBundle/Custom/User/Class
  service:
    mailer: ~

但是我得到这个错误:

InvalidArgumentException: $id must be a string, or an Alias object.

您需要注入noop-mailer。它不需要邮寄服务,也不会发送任何电子邮件。

fos_user:
  db_driver: orm 
  firewall_name: main
  user_class: acmeBundle/Custom/User/Class
  service:
    mailer: fos_user.mailer.noop

文档中确实提到了这一点。不想发邮件时可以指定fos_user.mailer.noop

您可以在电子邮件文档的 Default mailer implementations 章节中找到所有相关信息。