1
我需要使用spool选项向我的用户发送大量电子邮件,但是我不会将我的应用的整个配置更改为spool,因为我的注册系统发送给用户的电子邮件,我希望这封电子邮件能够即时发送。通过控制器和spool中的内存在Symfony2中的一些命令中发送电子邮件
有没有办法做到这一点,而无需更改swiftmailer的全局配置?
我需要使用spool选项向我的用户发送大量电子邮件,但是我不会将我的应用的整个配置更改为spool,因为我的注册系统发送给用户的电子邮件,我希望这封电子邮件能够即时发送。通过控制器和spool中的内存在Symfony2中的一些命令中发送电子邮件
有没有办法做到这一点,而无需更改swiftmailer的全局配置?
您可以配置不同的电子邮件程序。例如:
swiftmailer:
default_mailer: spool_mailer
mailers:
spool_mailer:
spool:
type: file
path: /path/to/spool
# ...
instant_mailer:
# ...
然后使用一个电子邮件使用者或其他取决于你是否想阀芯或不:
//in your controller
$spoolMailer = $this->get('swiftmailer.mailer.spool_mailer');
$spoolMailer->send(...); //this will be spooled
$instantMailer = $this->get('swiftmailer.mailer.instant_mailer');
$instantMailer->send(...); //this will be sent instantly
好像工作:) Thaks很多卡洛斯 –