4

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');

unairoldan
  • 2,775
  • 4
  • 28
  • 49
  • I opened an issue and was derived to existent one: https://github.com/symfony/SwiftmailerBundle/issues/7 – unairoldan Jun 27 '12 at 09:32
  • @Ztere0 in the GitHub issue that you where redirected to (https://github.com/symfony/SwiftmailerBundle/issues/6) stof said that it is possible to define a second mailer service. Did you manage to do that? – David Barreto Sep 04 '12 at 16:37
  • @David, not yet, but thanks by the response – unairoldan Sep 05 '12 at 17:55

3 Answers3

4

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"]
Community
  • 1
  • 1
David Barreto
  • 8,887
  • 7
  • 32
  • 46
  • Nice! But you may run into issues if one environment uses spooling and the other doesn't. You might want to check if `$this->get('mailer')->getTransport() instanceof \Swift_Transport_SpoolTransport` before switching to the .real transport since it may not exist! – bksunday Mar 13 '13 at 21:30
0

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.

Cris Favero
  • 632
  • 8
  • 16
-2

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

Omn
  • 2,982
  • 1
  • 26
  • 39