How to spool emails (in a task) and send normal emails in the moment in the other controllers?

僤鯓⒐⒋嵵緔 提交于 2019-12-03 16:47:57
David Barreto

I found the solution and posted here: How to define an additional mailer service to use the spool and send instant emails in Symfony2

In a nutshell:

instant_mailer:
    class: %swiftmailer.class%
    arguments: ["@?swiftmailer.transport.real"]

PEAR::Mail_Queue http://pear.php.net/package/Mail_Queue is specifically designed for spooling large amounts of mail to be sent. so i would use this specifically for all your non urgent messages and then use the general mail function or even Pear::Mail for the immediate ones.

According to the Symfony 1.4 documentation, you can use a the following call to send a message immediately (when you are using a spool strategy for the project overall):

$this->getMailer()->sendNextImmediately()->send($message);

This is a lot simpler than the accepted answer, and will be the correct solution if you do not need to send many spooled messages. I'd imagine the same, or a similar function exists in symfony2.

http://www.symfony-project.org/gentle-introduction/1_4/en/11-Emails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!