Symfony 在FOS_用户配置中设置两个不同于_的电子邮件

Symfony 在FOS_用户配置中设置两个不同于_的电子邮件,symfony,fosuserbundle,Symfony,Fosuserbundle,我使用的是symfony 2.3版本,我想在fos_用户配置中配置两个不同于_的电子邮件,如何可能以及在何处设置我的配置 我想在注册普通用户后使用normaluser@gmail.com并使用additionaluser@gmail.com 请推荐任何解决方案。您可以通过 创建自定义服务 例如: <?php namespace AppBundle\Mailer; // implement all the needed methods class CustomMailer implemen

我使用的是symfony 2.3版本,我想在fos_用户配置中配置两个不同于_的电子邮件,如何可能以及在何处设置我的配置

我想在注册普通用户后使用normaluser@gmail.com并使用additionaluser@gmail.com

请推荐任何解决方案。

您可以通过

创建自定义服务

例如:

<?php

namespace AppBundle\Mailer;
// implement all the needed methods
class CustomMailer implements MailerInterface
{
    public function sendConfirmationEmailMessage(UserInterface $user)
    {
        $template = $this->parameters['confirmation.template'];
        $url = $this->router->generate('fos_user_registration_confirm', array('token' => $user->getConfirmationToken()), UrlGeneratorInterface::ABSOLUTE_URL);
        $rendered = $this->templating->render($template, array(
            'user' => $user,
            'confirmationUrl' => $url,
        ));

        // implement the logic that decides which from_email to use
        // change the from_email accordingly

        $this->sendEmailMessage($rendered, $this->parameters['from_email']['confirmation'], (string) $user->getEmail());
    }

}
参考链接:


什么是“普通用户”和什么是“附加用户”?两个用户之间的不同之处在于附加用户访问的功能比普通用户多。谢谢回复。在哪里创建CustomMailer服务类??
fos_user:
    # ...
    service:
        mailer: app.custom_fos_user_mailer