Bor*_*mbo 2 memory email spool swiftmailer symfony
我需要使用spool选项向我的用户发送大量的电子邮件,但我不会将我的应用程序的整个配置更改为假脱机,因为我的注册系统向用户发送了一封电子邮件,我希望这封电子邮件能够即时发送.
有没有办法在不更改swiftmailer的全局配置的情况下执行此操作?
您可以配置不同的电子邮件.例如:
swiftmailer:
default_mailer: spool_mailer
mailers:
spool_mailer:
spool:
type: file
path: /path/to/spool
# ...
instant_mailer:
# ...
Run Code Online (Sandbox Code Playgroud)
然后使用一个电子邮件或另一个,取决于您是否要假脱机:
//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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
577 次 |
| 最近记录: |