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很多卡洛斯 –