问题
In my application we send notification emails at the moment, for example, when your registry, or when need to confirm some information via email.
But also we need to send personalized emails (only differenced in one text) for a hundreds of users, but I do not know how to combine Symfony2 spool email with no spool email in the same project.
There are something like a parameter when sending the email to indicate this?
Something like $email->send('no-spool');
回答1:
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"]
回答2:
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.
回答3:
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
来源:https://stackoverflow.com/questions/10741452/how-to-spool-emails-in-a-task-and-send-normal-emails-in-the-moment-in-the-othe