有没有一种方法可以在没有邮件服务的情况下使用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.

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

您可以在电子邮件文档的"默认邮件程序实现"一章中找到所有相关信息。

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

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